tags:

views:

48

answers:

1

I'm trying to filter a list of elements via ':not()', and jQuery seems to be ignoring my filter.

here is the code:

myElements.filter(':not(.someclass)');

jquery still selects all of myElements...

+6  A: 
myElements = myElements.filter(":not(.someClass)");
myElements.hide();

or:

myElements = myElements.not(".someClass");
myElements.hide();

Note you will actually need to assign the filtered collection to a variable to capture the change, otherwise nothing will visibly happen. If you don't want to do that, you can always use chaining to do what you need, e.g.:

myElements.filter(":not(.someClass)")
          .hide();
karim79