I am trying to change the text colour of individual cells in a table, based on the cell values using this code
if (field == "210299") {
results.css({'color':'red'});
}
The code works in that the colour is changed. But is also changed for all the other items in that column. If I apply multiple colours to different cell, the last one applied seems to override all the others, including cells which had no colour applied.
I don’t know what I’m doing, but this isn’t what I expected. Any suggestions please.
You are changing the color for the entire column ( through the results.css() method). What you want is to specifically target the current cell, which is what the this object represents inside the .each() method.
So replace the results.css() statement with: