jQuery nextAll() method
Example
Return each with class name "start"
$(document).ready(function(){
$("li.start").nextAll().css({"color":"red","border":"2px solid red"});
});
Result:
- li (sibling)
- li (sibling)
- li (sibling with class name "start")
- li (sibling)
- li (sibling)
- li (sibling)
Try it »
Definition and Usage
The nextAll() method returns all sibling elements after the selected element.
Sibling elements are elements that share the same parent element.
**DOM Tree:** This method traverses forward along the sibling elements of the DOM element.
Related methods:
- next() - returns the next sibling element of the selected element
- nextUntil() - returns all sibling elements after each element between two given arguments
Syntax
$(
selector
).nextAll(
filter
)
| Parameters | Description |
|---|---|
| filter | Optional. Specifies a selector expression to narrow down the search for sibling elements after the element. |
**注意:**如需返回多个同级元素,请使用逗号分隔每个表达式。 |
More examples
Narrow down the search
How to filter the search for sibling elements after the element.
Return multiple sibling elements
How to use the filter parameter to return those with class names "1", "2", and "3"
all sibling elements of the element.
all sibling elements after the
How to select
all sibling elements after the.
Element
How to select each
jQuery Traversal Methods