I have a table with many rows. In each row there is a cell with an id of 'overwrite'. If overwrite contains a number > 0 than I would like to change the background color of the cell to red.
I have javascript that looks like this:
$('#overwrite').each(function() {
if (parseInt($(this).text()) > 0) {
$(this).addClass('records_overwritten');
}
});
This only changes the background color of one cell, and none of the others even though they also contain a value greater than 0. I am a bit confused what the issue is.
Here is an example of a table row:
<tr>
<td>March 18, 2014</td>
<td>John Smith</td>
<td>5</td>
<td>10</td>
<td id="overwrite">1</td>
<td>56</td>
</tr>