English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The nextAll() method returns all subsequent sibling elements of the selected element.
Sibling elements must have the same parent element.
$(selector).nextAll(selectorExpression)
Returns elements with id="div-1element's all next sibling elements:
$("document").ready(function(){ $("#div-1).nextAll().css("background", "mediumpurple"); });Test it out‹/›
Returns all next sibling elements of each DIV element:
$("document").ready(function(){ $("div").nextAll().css("background", "lightblue"); });Test it out‹/›
Returns all next sibling elements of each DIV element, which is the same as $("div ~ p"):
$("document").ready(function(){ $("div").nextAll("p").css("background", "lightblue"); });Test it out‹/›
Parameter | Description |
---|---|
selectorExpression | (Optional) A selector expression, element, or jQuery object to match the element Note:To return multiple siblings, separate each expression with a comma |