views:

27

answers:

2

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();
    }
});

Is that possible to do the same in easier way ?

+5  A: 

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

elusive
Great, thanks a lot !!
Misha Moroshko
You're welcome!
elusive
A: 
$('#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 ?

Rakesh Juyal