I have a table that has some rows in it.
Here is an example of my table just with alot less table rows.
<table>
<tr>
<td>bob</td>
<td class="CheckThis">0 </td>
</tr>
<tr>
<td>Jim</td>
<td class="CheckThis">3</td>
</tr>
</table>
Now I want to look at the second table cells and get rows back that have value greater then 0.
So in my above example it would get the entire row that contains "3" since it is greater then zero.
I don't see any sectors that do greater then something in jquery but I could have just missed it.
thanks
Try this:
$("tr").filter(function() {
return parseInt($(this).children("td.CheckThis").text(), 10) > 0;
})
This will select you each TR element that has a TD child element with the class CheckThis that’s content is greater than 0.
You can use the filter()
function for this.
E.g.
var tds = $('td.CheckThis').filter(function() {
return parseInt($(this).text()) > 0;
});
Update: after rereading the question once more, you actually want to select the tr
elements containing the td
's in question and thus not only the td
's. In this case, please checkout Gumbo's answer for another code example which does that right.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With