More than a selector in jquery?

I have a table in which there are several rows.

Here is an example of my table with only fewer 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 cells of the second table and return rows whose value is greater than 0.

So, in my previous example, it will get the whole line containing "3", since it is greater than zero.

I do not see sectors that do something more in jquery, but I could just skip this.

thank

+3
source share
4 answers

Try the following:

$("tr").filter(function() {
    return parseInt($(this).children("td.CheckThis").text(), 10) > 0;
})

This will select every TR element that has a TD child, with a CheckThis class whose contents are greater than 0.

+5
source

filter().

.

var tds = $('td.CheckThis').filter(function() {
    return parseInt($(this).text()) > 0;
});

: , tr, td, , , td. , , Gumbo , .

+4

Of course gt should do it. Browse docs in Selectors / gt

Edit: Oh, are you talking about the value in the HTML element? You may have to set up a .each loop with a filter or something else. I'll check it out, sorry.

0
source
var list = [];
$("table").find("tr td:eq(1):not(:contains('0'))").each(function(i,val){
    list.push($(this).parent()); //add TR
});
0
source

Source: https://habr.com/ru/post/1727885/


All Articles