hi
I'm trying to add a js code to change the background color of a td based on a value. i created a js file named list_47.js the number is the id of the list respectively. i added a js list plugin and called the file. unfortunately it is not working. this is my code
thanks
I'm trying to add a js code to change the background color of a td based on a value. i created a js file named list_47.js the number is the id of the list respectively. i added a js list plugin and called the file. unfortunately it is not working. this is my code
thanks
Code:
var allTableCells = document.getElementsByTagName("td class");
for(var i = 0, max = allTableCells.length; i < max; i++) {
var node = allTableCells[i];
var currentVal = parseFloat(node.childNodes[0].nodeValue);
if(currentVal != NaN){
if (currentVal <0)
node.style.backgroundColor = "red";
}
else if (currentVal != NaN) {
if (currentVal >=1 && currentVal <=10 )
node.style.backgroundColor = "yellow";
}
}