English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The next() method returns the next sibling element of the selected element.
Sibling elements must have the same parent element.
Note:This method returns only one element.
$(selector).next(selectorExpression)
Returns the element with id="div-1Element's next sibling element:
$("document").ready(function(){ $("#div-1).next().css("background", "mediumpurple"); });Test and see‹/›
Returns the next sibling element of each DIV element:
$("document").ready(function(){ $("div").next().css("background", "lightblue"); });Test and see‹/›
Returns the next sibling element of each DIV element, equivalent to $("div + p") functions the same as:
$("document").ready(function(){ $("div").next("p").css("background", "lightblue"); });Test and see‹/›
Parameter | Description |
---|---|
selectorExpression | An optional selector expression, element, or jQuery object to match elements |