.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.
Remember
$("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)
Select a starting sibling, then collect everything after it.
Select the starting element (e.g. $("li.third-item")).
Call .nextAll() for every following sibling.
Or pass a selector: .nextAll("p") to keep matching tags only.
Chain methods on the new set (.append(), .each(), …).
Need the start too? Chain .addBack().
Piece
Required?
Role
Matched set
Yes
Starting element(s)
selector
No
Keep only matching following siblings
Direction
—
Forward only (after the start)
Return value
—
New jQuery set (0 or more)
Pseudocode
Pseudocode
call $(starts).nextAll(selector?)
result = empty set
for each start in the matched set:
sibling = start.nextElementSibling
while sibling is not null:
if no selector OR sibling matches selector:
add sibling to result
sibling = sibling.nextElementSibling
return result as a new jQuery object
(start itself is never included)
Reference
Cheat Sheet
Keep these sibling methods side by side.
Topic
Detail
Syntax
.nextAll([selector])
Since
jQuery 1.2
Includes start?
No (use .addBack())
vs .next()
One sibling vs all following
vs .nextUntil()
All following vs until a stop
vs .prevAll()
Forward vs backward
DOM change?
No — query only
Try it
Live Preview
From li.third-item, compare .next(), .nextAll(), and .addBack().
One line:.nextAll() grabs every sibling after the current element — not the element itself.
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.