Latest web development tutorials

jQuery next () method

jQuery traversal methods jQuery traversal methods

Examples

After returning each <li> element with the class name "start" of a sibling element:

$(document).ready(function(){
$("li.start").next().css({"color":"red","border":"2px solid red"});
});

result:

    ul (parent)
  • li (sibling)
  • li (sibling)
  • li (sibling with class name "start")
  • li (sibling)
  • li (sibling)

try it"

Definition and Usage

next () method returns after being selected elements of a sibling element.

Sibling elements are elements that share the same parent element.

Note: This method returns only one element.

DOM tree: When the DOM element method along a sibling element forward traversal.

Related methods:

  • nextAll () - Returns all sibling elements after the selected element
  • nextUntil () - Returns all two siblings to each element of the given parameters after the

grammar

$(selector).next( filter )

参数 描述
filter 可选。规定缩小搜索后一个同级元素范围的选择器表达式。

Examples

More examples

Select each <div> element after a sibling element
How to select each of the <div> element after a sibling element.

Narrow your search
How to select each of the <div> element after a sibling <p> element.


jQuery traversal methods jQuery traversal methods