Easy Tutorial
❮ Ajax Ajaxstop Jquery Ref Effects ❯

jQuery siblings() Method

jQuery Traversing Methods

Example

Return all sibling elements of each <li> element with the class name "start":

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

Result:


Definition and Usage

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

Sibling elements are elements that share the same parent.

DOM Tree: This method traverses forward and backward along the sibling elements of the DOM elements.

Tip: Use the prev() or next() methods to narrow the search to only the previous sibling element or the next sibling element.


Syntax

Parameter Description
filter Optional. Specifies a selector expression to narrow down the search for sibling elements.

More Examples

Narrow Down the Search

Select All Sibling <p> Elements of Each <div> Element


jQuery Traversing Methods

❮ Ajax Ajaxstop Jquery Ref Effects ❯