- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery :root Selector
The :root selector in jQuery is used to select the document's root element.
Syntax
The syntax is as follows −
$(":root")
Example
Let us now see an example to implement the jQuery :root selector −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(":root").css("color", "red"); }); </script> </head> <body> <h1>Heading One</h1> <h2>Heading Two</h2> <p>Demo text...</p> </body> </html>
Output
This will produce the following output −
Advertisements