Skip to content

Instantly share code, notes, and snippets.

@daniel-barrows
Last active March 22, 2019 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daniel-barrows/2fbfcbf46abe345227b5840bb4def529 to your computer and use it in GitHub Desktop.
Save daniel-barrows/2fbfcbf46abe345227b5840bb4def529 to your computer and use it in GitHub Desktop.
Change background color of cells in a table containing boolean values
/*
Author: Daniel Barrows
Copyright: 2019
License: Public Domain
Status: beta
*/
function color_table( selector = '.markdown-body td' ){
Array.from(document.querySelectorAll(selector)).forEach(function(i){
switch(i.innerText){
case "Y": i.style.backgroundColor = "PaleGreen"; break;
case "P": i.style.backgroundColor = "Khaki"; break;
case "N": i.style.backgroundColor = "LightSalmon"; break;
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment