Last active
March 22, 2019 11:56
-
-
Save daniel-barrows/2fbfcbf46abe345227b5840bb4def529 to your computer and use it in GitHub Desktop.
Change background color of cells in a table containing boolean values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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