I have a table
within an HTML
page that I would like to color all rows in red when the first column reaches a specific value.
After researching on StackOverflow
, I found suggestions to add these two attributes (border-collapse and border-spacing) to my table:
<table id="my-table" style="border-collapse:collapse; border-spacing:0 1px">
Now, how can I use JavaScript to set the background color based on a new value?
I attempted the following approaches:
if (value == 'broken') {my-table[i].css('background-color','red');} // OR
if (value == 'broken') {my-table[i].cells.style.background = 'red';}
where i is the index of the row I am targeting. However, no changes are visible! Can anyone provide me with advice? Thank you.