Set text color for cell data based on text or value

for text you can use == "Down" for numbers you can use > 5 or any of comparison operators

by Duke Dinh

HTML

<table>
<tr>
<td class="cell1">20</td>
<td class="cell1">Down</td>
<td class="cell1">1</td>
<td class="cell1">3</td>
<td class="cell1">10</td>
<td class="cell1">15</td>
</tr>
</table>

CSS

.cell1 { border:1px solid red; background:#eee; padding:10px; }

JavaScript

$('.cell1').each(function(i, n) {
   if($(n).text() == 'Down') $(n).css('color', 'green');
});