jQuery Tutorials
jQuery Effects
jQuery HTML
jQuery Traversing
jQuery AJAX
jQuery Misc
Basic filtering methods are first()
, last()
and eq()
, which allow you to select a specific element based on its location in the group of objects.
Some sorting methods, such as filter()
and not()
, allow you to select elements that are similar to, or do not match, certain conditions.
The first()
method returns the first part of the specified elements.
The following example selects the first <div>
item:
The last()
method returns the last part of the specified elements.
The following example selects the last part of <div>
:
The eq()
method returns an item with a specific index number of selected items.
Index numbers start at 0, so the first item will have a reference number 0 and not 1. The following example selects the second element of <p>
(reference number 1):
The filter()
method allows you to specify terms. Items that do not match the terms are removed from the selection, and the same ones will be returned.
The following example returns all <p>
features with class name "intro":
The not()
method returns all non-standard features.
Tip: The not()
method is opposite the filter()
.
The following example returns all <p>
features that do not have the class name "intro":