After creating a jQuery object using $(), we can alter the set of matched elements we are working with by calling one of these DOM traversal methods. DOM traversal methods are discussed in detail in Chapter 2, Selecting Elements.
DOM traversal methods
Filtering
Traversal method |
Returns a jQuery object containing... |
.filter(selector) |
Selected elements that match the given selector. |
.filter(callback) |
Selected elements for which the callback function returns true. |
.eq(index) |
The selected element at the given 0-based index. |
.first() |
The first selected element. |
.last() |
The final selected element. |
.slice(start, [end]) |
Selected elements in the given range of 0-based indices. |
.not(selector) |
Selected elements that do not match... |