简体   繁体   中英

Get the td with column-index > 3 and value > 6

I want to get the td with the column-index>3 and value>6 , I've written the code to get the td with an column-index>3 :

$.extend($.expr[':'], {
            gtchild: function (elem) {
          var $elem = $(elem),
            $row = $elem.parent();
        return  $row.find("td").index($elem) > 3;
    }
});

I can get the td with the value>6 like

return $row.find("td").text()>6

How do I combine them together?

Just combine your 2 conditions :

$.extend($.expr[':'], {
    gtchild: function (elem) {
        var $elem = $(elem),
            $row = $elem.parent();
        return $row.find("td").index($elem) > 3 && $elem.text() > 6;
    }
});

See this fiddle : http://jsfiddle.net/scaillerie/jjnUj/

Use something like

$row.children().slice(3).filter(function() {
    return parseInt($(this).text(), 10) > 6;
});

If you've got more than one row, switch to .find("td:nth-child(n+4)") .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM