The jQuery all selector selects every element of the HTML page. If you want to apply color to all the elements of a document. The jQuery all (“*”) selector is the best way to perform this task. It first, find every element of the document and then after applies the color to all the elements.
Let’s find out how to write it in jQuery using the syntax which is given below.
Syntax
1 |
$("*") |
Example
1 2 3 4 5 6 7 8 |
<script> $(document).ready(function(){ $("*").css("color", "#ccc"); }); </script> <h2>jQuery All Star("*") Selector</h2> <p>Welcome to Tutorialdeep!</p> <em>You are learning jQuery.</em> |
The above example applies the color to all the elements of the DOM using jQuery.
There are many elements in an HTML document. The jQuery all selector selects all the elements including the <html>
, <head>
and <body>
tag elements. It’s an easy way to apply the jQuery script to all the elements with a single specification.
You may also like to read
To learn more jQuery, you can read our step-by-step jQuery Tutorial Guide for beginners.