.nextAll([selector]) (since jQuery 1.2) returns all following siblings of each matched element — every sibling that comes after it under the same parent. Optional selector filters that set. Returns a new jQuery object; does not change the DOM.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$("li.third-item").nextAll(); // items 4 and 5
$("div").first().nextAll(); // all divs after the first
$(":nth-child(1)").nextAll("p"); // following p siblings only
$("li.third-item").nextAll().addBack(); // start + everything after
// next() → only the immediate next sibling
// nextAll() → all following siblings
// prevAll() → all preceding siblings
// siblings() → all siblings (before + after)
Call
What it does
Matched set
Starting element(s)
selector
Keep only matching following siblings
Direction
Forward only (after the start)
Return value
New jQuery set (0 or more)
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Select the starting element (e.g. $("li.third-item")).
Step 2
Call .nextAll() for every following sibling.
Step 3
Or pass a selector: .nextAll("p") to keep matching tags only.
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
jQuery Examples
Example 1 — All List Items After the Third
Official idea: from li.third-item, mark every following li.
Following p siblings get [p]
Intervening div siblings are skipped by the filter
How It Works
Start. First child of the parent (often the first p).
Walk. Consider every following sibling.
Filter. Keep only those matching "p".
Frequently Asked Questions
.nextAll() returns a new jQuery object with all following siblings of each element in the current set — every sibling that comes after it under the same parent. An optional selector filters which of those siblings are kept.
.next() returns only the immediate next sibling (zero or one). .nextAll() returns every following sibling (zero or more). Use .next() for “the next one”; use .nextAll() for “everything after.”
.prevAll() collects preceding siblings (before the element). .siblings() collects all siblings both before and after — not including the element itself. .nextAll() only looks forward.
No. Only siblings that follow it. To include the start as well, chain .addBack() — for example $("li.third-item").nextAll().addBack().
.nextAll(selector) keeps only following siblings that match the selector — for example .nextAll("p") keeps following paragraph siblings and skips divs in between.
No. Like other jQuery traversing methods, it only queries the existing DOM and returns a new collection.