1
Reply

What is .siblings() method in jQuery?

Rohan  Rathore

Rohan Rathore

11y
7k
0
Reply

    .siblings() method allows us to search through the siblings of the elements on which jquery logic is performed. Use this editor:- http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_siblings And run this code:- list item 1,list item 2,list item4,list item 5 will highlight. These are none other than siblings of list item3. In the same way you can change the above written jquery to:- "$( "li" ).siblings('.third-item').css( "background-color", "red" );" Theis will highlight the list item 3 because it is now searching the sibling of li whose class is '.third-tem'.