开发者

Is that possible to select all elements that does not match a selector?

I have a table with lots of rows.

I would like to select all rows that does not match some selector.

For example:

$('#my_table tr').each(function() {
    if ($(this).find(".class_a.class_b[my_param='" + my_value + "']").length > 0) {
        $(this).do_something();
    }
});

I开发者_运维百科s that possible to do the same in easier way ?


Have a look at jQuery's :not()-selector. It excludes elements from the current selection set.


$('#my_table tr').not('.class_a').each(function(){
   // do something
}
);

the above code will select all rows that are in table with ID='my_table' and whose classname is not 'class_a' . Is this what you needed ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜