Skip to content
Related Articles

Related Articles

jQuery | :root Selector
  • Last Updated : 01 Mar, 2019

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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


Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :