I'm trying to filter a list of elements via ':not()', and jQuery seems to be igno开发者_StackOverflow中文版ring my filter.
here is the code:
myElements.filter(':not(.someclass)');
jquery still selects all of myElements...
myElements = myElements.filter(":not(.someClass)");
myElements.hide();
or:
myElements = myElements.not(".someClass");
myElements.hide();
You will actually need to assign the filtered collection to a variable to capture the modified (filtered) collection, otherwise you are effectively just referencing myElements
in its initial state. If you don't want to do that, you can always use chaining, for example:
myElements.filter(":not(.someClass)")
.hide();
精彩评论