electricphp
Programmer
I have this function that changes the background color of a table row but it's not working correctly.
If I invoke the function it will change the color from #a2dd51 to #ffff99, so normally if I invoke the function again, nothing should happen, since the color has been changed. But if I invoke it again, the alert still shows #a2dd51 even though on the page I can see the color changed accordingly
Code:
function changeColor(activeRow){
alert(document.getElementById("myTable").rows[activeRow].bgColor);
if (document.getElementById("myTable").rows[activeRow].bgColor == '#a2dd51')
{document.getElementById("myTable").rows[activeRow].style.backgroundColor = '#ffff99';}
}
If I invoke the function it will change the color from #a2dd51 to #ffff99, so normally if I invoke the function again, nothing should happen, since the color has been changed. But if I invoke it again, the alert still shows #a2dd51 even though on the page I can see the color changed accordingly