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

jQuery siblings() Method

jQuery Traversal Methods

The siblings() method returns all sibling elements of the selected elements.

同级元素必须具有相同的父元素。

Sibling elements must have the same parent element.Please useprev()ornext()

Methods to narrow the scope of searching to just the previous sibling element or the next sibling element.

Syntax:

$("selector").siblings(selectorExpression)

Instance

$("document").ready(function(){
  Return all sibling elements for each <li> element with the class 'middle':-color", "lightgreen");
});
Test and see‹/›

Return all siblings with the class 'bold' for each list item:

$("document").ready(function(){
  $("li").siblings(".bold").css("background-color", "lightgreen");
});
Test and see‹/›

Parameter Value

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

jQuery Traversal Methods