siblings() in jQuery

siblings() function used to find the siblings of given elements(s) . Siblings() elements shares the same parents always.

Syntax : 

$(selector).siblings(filter)

Consider a page with a simple list on it:

If we begin at the third item, we can find its siblings:

$('li.second-item').siblings().css('background-color', 'green');

 

Leave a Reply

Your email address will not be published. Required fields are marked *