jQuery next() method
Example
Return each with class name "start"
$(document).ready(function(){
$("li.start").next().css({"color":"red","border":"2px solid red"});
});
Result:
- li (sibling)
- li (sibling)
- li (sibling with class name "start")
- li (sibling)
- li (sibling)
Try it »
Definition and Usage
The next() method returns the next sibling element of the selected element.
Sibling elements are elements that share the same parent element.
**Note:** This method returns only one element.
**DOM Tree:** This method traverses forward along the next sibling elements of the DOM element.
Related methods:
- nextAll() - returns all sibling elements after the selected element
- nextUntil() - returns all sibling elements after each element between two given arguments
Syntax
$(
selector
).next(
filter
)
| Parameters | Description |
|---|---|
| filter | Optional. Specifies a selector expression to narrow down the search for the next sibling element. |
More examples
the next sibling element of the
How to select each
How to select each
the next sibling element of the.
Narrow down the search
How to select each
jQuery Traversal Methods