English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery next() Method

jQuery Traversal Methods

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.

Syntax:

$(selector).next(selectorExpression)

Example

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 Value

ParameterDescription
selectorExpressionAn optional selector expression, element, or jQuery object to match elements

jQuery Traversal Methods