I am looping into html tables cell and I would like to check the cells color if it is equal to a specific color code.
if I alert 'cell.style.backgroundColor' I get the result of rgb(0,0,0) But if I check it like this :
if(cell.style.backgroundColor=="#000")
{
alert("ok");
}
or this one :
if(cell.style.backgroundColor=="rgb(0,0,0)")
{
alert("ok");
}
I always get false.
Any ideas?
CodePudding user response:
You have to add the spaces after the commas: "rgb(0, 0, 0)"
not "rgb(0,0,0)"
CodePudding user response:
Try it:
window.getComputedStyle(cell, null).backgroundColor
And test it in different browsers, maybe each one can get with different kind of format.