I have this code which works fine :
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function()
{
$j('.Grid tr.myid').each(function()
{
var test = $j(this).html().indexOf("0");
if (test !=-1) {
$j(this).addClass("RowRed");
}
});
});
</script>
Example in html:
<table>
<tr class='myid'><td>value1</td><td>0</td></tr>
<tr class='myid'><td>value2</td><td>150</td></tr>
</table>
But I need to check if the value of a column in tr is < 0, and then change it’s background color. With this code I can’t, because it’s looking for a static value for example JMG.
It seems that you want to get the text content of the second
tdelements, instead ofhtmlyou can usetextmethod, which returns the text content of an element.