jQuery | :root Selector
The :root selector in jQuery is used to select the root element of document.
Syntax:
$(":root")
Parameter: This selector contains single parameter root which is the root element of document.
Example: This example use :root selector to select document and set background-color to green.
<!DOCTYPE html> <html> <head> <title> jQuery :root Selector </title> <script src= </script> </head> <body style = "text-align:center;"> <h1>GeeksForGeeks</h1> <h2>jQuery :root Selector</h2> <!-- Script uses :root selector --> <script> $(document).ready(function() { $(":root").css("background-color", "green"); }); </script> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- CSS | :root Selector
- jQuery | :first Selector
- jQuery | :last Selector
- jQuery | :odd Selector
- jQuery | :even Selector
- jQuery | #id Selector
- jQuery | * Selector
- jQuery | :contains() Selector
- jQuery | :has() Selector with example
- jQuery | :gt() Selector
- jQuery | :not() Selector
- jQuery | :lt() Selector
- jQuery | :header Selector
- jQuery | element + next Selector
- jQuery | :checked 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.



