jQuery siblings method

jQuery siblings method : jQuery “siblings() Method ” is used to get all siblings of the selected element. It returns the all siblings of the selected element. It accepts one parameter as filter which is optional. We are going to explain this method with the help of example and demo.

Syntax : jQuery siblings method

Syntax of siblings method


filter : It is optional, A selector expression is used to match(siblings) the elements against.

jQuery siblings Method Example

Here is an example of siblings method Click on Try it button to see the output-

jQuery siblings() Method – Example

<script type="text/javascript">
              $( "#prevUntilExample" ).on( "click", function(event) {             
                 $(".my-siblings").siblings().css("border","1px solid green");

Try it »

The above example will produce the following output-

Note : Below out is produced when you click on the Click to run siblings() Example button. To experience this demo click on the above “Try it” button.

jQuery siblings method


Add Comment

📖 Read More