jQuery | element ~ siblings Selector
The element ~ siblings selector in jQuery is used to select all elements that are siblings of the specified element.
Syntax:
("element ~ siblings")
Parameter: It contains two parameters as mentioned above and described below:
- element: It is required parameter and used for any valid jQuery selector.
- siblings: It is required parameter and used for specifying the siblings of the element parameter.
Example:
<!DOCTYPE html> <html> <head> <title> jQuery element ~ siblings Selector </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h2> jQuery element ~ siblings Selector </h2> <p>Geeks1</p> <div> <p>Geek2</p> <p>Geeks3</p> </div> <p>Geek4</p> <p>Geeks5</p> <div> <p>Geek6</p> </div> <script src= </script> <script> $(document).ready(function(){ $("div ~ p").css("background-color", "green"); }); </script> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- jQuery | element Selector
- jQuery | element + next Selector
- jQuery | Traversing Siblings
- jQuery | siblings() with Examples
- jQuery | :has() Selector with example
- jQuery | :not() Selector
- jQuery | :first Selector
- jQuery | :last Selector
- jQuery | * Selector
- jQuery | :gt() Selector
- jQuery | :odd Selector
- jQuery | :lt() Selector
- jQuery | #id Selector
- jQuery | :even Selector
- jQuery | :contains() Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



