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.
Traversal Method |
Returns a jQuery object containing… |
---|---|
|
Selected elements that match the given selector. |
|
Selected elements for which the |
|
The selected element at the given 0-based index. |
|
Selected elements in the given range of 0-based indices. |
|
Selected elements that do not match the given selector. |
Selected elements, plus any additional elements that match the given selector. | |
Descendant elements that match the selector. | |
|
Child nodes (including text nodes). |
|
Child nodes, optionally filtered by a selector. |
|
The sibling immediately following each selected element, optionally filtered by a selector. |
|
All siblings following each selected element, optionally filtered by a selector. |
|
The sibling immediately preceding each selected element, optionally filtered by a selector. |
|
All siblings preceding each selected element, optionally filtered by a selector. |
|
All siblings, optionally filtered by a selector. |
|
The parent of each selected element, optionally filtered by a selector. |
|
All ancestors, optionally filtered by a selector. |
|
The first element that matches the selector, starting at the selected element and moving up through its ancestors in the DOM tree. |
|
The positioned parent (e.g. |
|
The selected elements, plus the previous set of selected elements on the internal jQuery stack. |
The previous set of selected elements on the internal jQuery stack. | |
The result of the |