I have a div that I want to change color based on the int value in the div, but for some reason it doesn't change the color based on the if else statement I wrote. Instead no color appears. Why is that?
<div id="test">66</div>
JAVASCRIPT
var testDiv = document.getElementById("test");
if (testDiv<50) {
testDiv.style.backgroundColor = '#900000';
} else if (testDiv > 49 && testDiv < 75) {
testDiv.style.backgroundColor = '#FF9933';
} else if (testDiv > 74) {
testDiv.style.backgroundColor = '#00CC00';
}
testDivbe a number, or in any way comparable to a number, it's clearly an elementparseInt( testDiv.innerHTML, 10)