The jQuery * selector selects all the elements in the document, including HTML, body, and head. If the * selector is used together with another element then it selects all child elements within the element used.
syntax
$("*")
Example-1: Selects all element and change background color.
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).ready(function() { $("*").css("background-color", "lightgreen"); }); </script> </head> <body> <center> <h1>Welcome to geeksforgeeks </h1> <p>My name is akash.</p> <p>I live in mathura.</p> <p>My best friend is ajay. </p> <p>Who is your favourite: </p> <ul type="square"> <li>virat</li> <li>akshay</li> </ul> </center> </body> </html> |
chevron_right
filter_none
Output:

Example-2: Selects all element and change background color.
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).ready(function() { $("*").css("background-color", "green"); }); </script> </head> <body> <h1>GeeksForGeeks</h1> <p>cricket is religion in india </p> <p>sachin is god of cricket. </p> <p>records:</p> <ul type="circle"> <li>100 centuries</li> <li>highest run scorer</li> </ul> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- jQuery | :contains() Selector
- jQuery | :lt() Selector
- jQuery | :even Selector
- jQuery | :not() Selector
- jQuery | :first Selector
- jQuery | :odd Selector
- jQuery | #id Selector
- jQuery | :has() Selector with example
- jQuery | :last Selector
- jQuery | :gt() Selector
- jQuery | :first-of-type Selector
- jQuery | animated Selector with Example
- jQuery | :last-of-type Selector
- How to get a DOM Element from a jQuery Selector ?
- jQuery | :nth-last-child() Selector
- jQuery | [attribute!=value] Selector
- jQuery | [attribute*=value] Selector
- jQuery | :lang() Selector
- jQuery | :empty Selector
- jQuery | :checkbox 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.

