jQuery Traversing Methods

Beginner
8 min read
Updated: Nov 2026
32 method guides
Method index

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().

Beginner path.

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:

jQuery
$("#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 (32 tutorials).

Descendants

3 methods

Move down the tree — find nested matches, direct children, or all child nodes.

MethodDescriptionTutorial
.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 methods

Move up the tree — parent, parents, closest, and positioned offset parents.

MethodDescriptionTutorial
.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 methods

Move sideways — next, previous, and all siblings at the same level.

MethodDescriptionTutorial
.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

10 methods

Narrow or test the current set — by selector, index, or descendant containment.

MethodDescriptionTutorial
.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
.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 methods

Loop over matched elements — side effects with .each() or collect with .map().

MethodDescriptionTutorial
.each()Iterate over each matched element with a callback (index, element).Try it
.map()Pass each element through a callback and build a new jQuery object from returns.Try it

Collection & Stack

5 methods

Union sets and manage jQuery’s internal selection stack.

MethodDescriptionTutorial
.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

Frequently Asked Questions

Traversing methods move through the DOM from a current selection—down with .find(), up with .parent()/.closest(), sideways with .next()/.siblings(), or narrow the set with .filter()/.eq(). They return new collections without inserting HTML.
.children() only looks one level down. .find() searches all descendants at any depth. Prefer .children() when you know the structure is flat; use .find() for nested trees.
.closest() returns the first match walking up (including the element itself). .parents() returns all ancestors. Use .closest() for 'nearest container'; use .parents() when you need the full chain.
jQuery keeps a stack of previous selections. .end() pops back to the previous set. .addBack() merges the previous set into the current one—handy after .find() when you still need the parent.
Start with .find() and .children(), then .parent() / .closest() and .next() / .siblings(). Learn .filter() and .eq() when you need to narrow a set.

Start with .find()

Open the descendants guide—syntax, examples, and FAQs.

.find() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

16 people found this page helpful