- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to use universal (*) selector in jQuery?
The universal selector selects all the elements available in the document. Here’s how to use it:
$('*')
Example
You can try to run the following code to learn how to implement Universal Selector in jQuery −
<html> <head> <title>jQuery Universal Selector</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { /* This would select all the elements */ $("*").css("background-color", "yellow"); }); </script> </head> <body> <div class = "big" id = "div1"> <p>This is first division of the DOM.</p> </div> <div class = "medium" id = "div2"> <p>This is second division of the DOM.</p> </div> <div class = "small" id = "div3"> <p>This is third division of the DOM</p> </div> </body> </html>
- Related Articles
- Is it possible to use $(this) and universal selector (*) with jQuery?
- How to use *= operator in jQuery attribute selector?
- How do we use # in jQuery Attribute Selector?
- How do we use jQuery selector eq:()?
- Universal Selector in CSS
- How do we use .not() with jQuery selector?
- How do we use jQuery Attribute selector with a period?
- How to escape square brackets in jQuery selector?
- How do we use wildcard or regular expressions with a jQuery selector?
- How to combine a class selector and an attribute selector with jQuery?
- jQuery :button Selector
- jQuery :checkbox Selector
- jQuery :checked Selector
- jQuery :contains() Selector
- jQuery :disabled Selector

Advertisements