jQuery Traversing Methods

About This Index
This page is the jQuery Traversing index for the tutorial track. Each row links to a full guide with syntax, examples, and FAQs.
Learn the jQuery overview on /jquery. Use this page when you need a Traversing API such as .find(), .closest(), or .filter().
Start with .find() and .children(), then .parent() / .closest() and .next() / .siblings()—add .filter() and .eq() when you need to narrow a set.
How to Call a Traversing Method
Start from a selection, then move through the tree or narrow the set:
$("#list").find("li.active");
$("#list").children("li");
$("a").closest("nav");
$("li").next().addClass("after");
$("li").siblings(".selected");
$("li").filter(".done");
$("li").eq(0);
$("li").first().end().last(); // stack: back with .end()
$("#a").add("#b"); // union collections jQuery Traversing Methods Table
All Traversing method guides in this jQuery tutorial series (34 tutorials).
Descendants
3 methodsMove down the tree — find nested matches, direct children, or all child nodes.
| Method | Description | Tutorial |
|---|---|---|
.find() | Get descendants of each matched element — filtered by a selector, jQuery object, or DOM element. | Try it |
.children() | Get direct child elements one level down — optionally filtered by a selector. | Try it |
.contents() | Get all direct child nodes — elements, text, and comments. | Try it |
Ancestors
5 methodsMove up the tree — parent, parents, closest, and positioned offset parents.
| Method | Description | Tutorial |
|---|---|---|
.parent() | Get the immediate parent of each matched element — optionally filtered by a selector. | Try it |
.parents() | Get every ancestor up toward html — optionally filtered by a selector. | Try it |
.parentsUntil() | Get ancestors up to but not including a stop selector, node, or jQuery object. | Try it |
.closest() | Walk up from each element (including self) and return the first matching ancestor. | Try it |
.offsetParent() | Get the closest positioned ancestor — CSS relative, absolute, or fixed. | Try it |
Siblings
7 methodsMove sideways — next, previous, and all siblings at the same level.
| Method | Description | Tutorial |
|---|---|---|
.next() | Get the immediately following sibling — optionally filtered by a selector. | Try it |
.nextAll() | Get all following siblings — optionally filtered by a selector. | Try it |
.nextUntil() | Get following siblings up to but not including a stop selector or node. | Try it |
.prev() | Get the immediately preceding sibling — optionally filtered by a selector. | Try it |
.prevAll() | Get all preceding siblings — optionally filtered by a selector. | Try it |
.prevUntil() | Get preceding siblings up to but not including a stop selector or node. | Try it |
.siblings() | Get all siblings of each matched element — optionally filtered by a selector. | Try it |
Filtering
11 methodsNarrow or test the current set — by selector, index, or descendant containment.
| Method | Description | Tutorial |
|---|---|---|
.filter() | Keep elements that match a selector, pass a callback, or appear in a given set. | Try it |
.not() | Remove elements that match a selector, callback, or given set. | Try it |
.has() | Keep elements that have a descendant matching a selector or DOM element. | Try it |
.index() | Get an element's position among its siblings, or search within a selector, element, or jQuery set. | Try it |
.is() | Return true if at least one matched element matches a selector or test. | Try it |
.first() | Reduce the set to the first element — equivalent to .eq(0). | Try it |
.last() | Reduce the set to the last element — equivalent to .eq(-1). | Try it |
.eq() | Reduce the set to the element at a zero-based index (negative from the end). | Try it |
.slice() | Reduce the set to a range of indices — like Array.prototype.slice. | Try it |
.even() | Keep elements at even zero-based indexes — 0, 2, 4… | Try it |
.odd() | Keep elements at odd zero-based indexes — 1, 3, 5… | Try it |
Iteration
2 methodsLoop over matched elements — side effects with .each() or collect with .map().
Collection & Stack
6 methodsUnion sets and manage jQuery’s internal selection stack.
| Method | Description | Tutorial |
|---|---|---|
.add() | Create a new collection that unions the current set with more elements. | Try it |
.addBack() | Add the previous stack selection to the current set — optionally filtered. | Try it |
.andSelf() | Legacy alias of .addBack() — deprecated 1.8, removed in jQuery 3.0. | Try it |
.end() | Pop the traversal stack and restore the previous matched set. | Try it |
.pushStack() | Push DOM elements onto the selection stack — for plugins and custom traversal. | Try it |
.uniqueSort() | Sort a jQuery collection in document order and remove duplicate nodes (jQuery 3.7+). | Try it |
Frequently Asked Questions
Start with .find()
Open the descendants guide—syntax, examples, and FAQs.
CODETOFUN NEWS
Stay Ahead in Tech
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
16 people found this page helpful
