Filtering
jQuery provides methods for filtering the current selection.
method | description |
---|---|
filter(sel | cb) | Creates a new jQuery object by filtering the collection using a given selector or callback function. The sel parameter can be
The cb callback must return a boolean value. It has two parameters:
|
not(sel | cb) | Creates a new jQuery object by removing the specified elements using a given selector or callback function. The sel parameter can be
The cb callback must return a boolean value. It has two parameters:
|
even() | Creates a new jQuery object from the even elements. Counting starts from zero. |
odd() | Creates a new jQuery object from the odd elements. Counting starts from zero. |
end() |
Ends the most recent filtering operation in the current chain and returns previous state. Some methods create a new jQuery object based on the current jQuery object. When this happens, a new object will be pushed onto the stack, which is stored inside the object. If you want to revert to the previous selection, call this method. |