.next([selector]) (since jQuery 1.0) returns the immediately following sibling of each element in the set. With an optional selector, that sibling is kept only if it matches.
Remember
$("li.third-item").next(); // item 4
$("button[disabled]").next(); // next sibling after each disabled button
$("p").next(".selected"); // next sibling only if it has .selected
// Not the same:
$("li").nextAll(); // all following siblings
Start from an element, then take one step to the right in the sibling list.
Select the starting element(s).
Call .next() for the immediate following sibling.
Optionally pass a selector to keep that sibling only if it matches.
If no next sibling (or no match), the result is empty — chaining is still safe.
Style or act on the returned set.
Piece
Required?
Role
Current set
Yes
Elements whose next sibling you want
selector
No
Keep the next sibling only if it matches
Return value
—
New jQuery object (0 or more next siblings)
Pseudocode
Logic
for each element E in current set
N = immediate next element sibling of E
if N does not exist
skip
else if selector provided and N does not match selector
skip
else
keep N
Quick ref
Cheat Sheet
Goal
Code
Next sibling
$("li.start").next()
Next only if class matches
$("p").next(".selected")
Label after disabled buttons
$("button[disabled]").next()
Previous sibling
$("li.start").prev()
All after this one
$("li.start").nextAll()
Check if a next exists
if ($el.next().length) { … }
Try it
Live Preview
Start at item 3 and compare .next(), .nextAll(), and .prev().
list item 1
list item 2
list item 3 (start)
list item 4
list item 5
Start is item 3. Item 4 has class mark.
Result
Ready — click Run to traverse.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Official List Demo
From the jQuery docs: red background on the item right after li.third-item.
.next() has been part of jQuery since 1.0. It works in every browser where jQuery runs — a core traversing method with no deprecation.
✓ jQuery 1.0+
jQuery .next()
Stable across jQuery 1.x–3.x. Optional selector filter has been available since the method was introduced.
StableStatus
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.next()Since 1.0
Bottom line: Safe for production and learning. Pair with .prev(), .nextAll(), and .siblings() for full sibling navigation.
Analysis
Performance Notes
Approach
Cost
Best for
.next()
Cheapest
One-step sibling moves
.nextAll()
More work
Collecting every following sibling
.siblings()
More work
Both directions at once
Prefer .next() when you only need the immediate neighbor. Wider methods walk more of the sibling list.
Remember
Key Takeaways
Role: one step to the immediately following sibling — since 1.0.
Filter:.next(sel) keeps that sibling only if it matches — no skipping.
vs .nextAll(): one neighbor vs all following.
Mirror:.prev() does the same step backward.
One line:.next() returns the immediate next sibling — use .nextAll() when you need everything after.
Frequently Asked Questions
.next() returns the immediately following sibling of each element in the current set. It moves sideways in the DOM — not into children and not up to parents. Without a selector, the very next element sibling is included if one exists. Available since jQuery 1.0.
.next() returns at most one sibling — the direct next neighbor. .nextAll() returns every following sibling. From list item 3, .next() gives item 4 only; .nextAll() gives items 4 and 5.
.next() looks forward to the following sibling; .prev() looks backward to the preceding sibling. Same distance (one step), opposite direction.
jQuery returns an empty collection (length 0). Chaining stays safe: .next().addClass("x") does nothing when no neighbor exists. Check .next().length when you need a boolean.
No. .next(selector) tests only the immediately following sibling. If that sibling does not match, the result is empty — jQuery does not keep scanning. Use .nextAll(selector).first() when you need the next match further along.
Yes. jQuery runs .next() for each element in the set and combines the results. $("p").next() returns the next sibling of every paragraph.