- Trending Categories
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 element Selector
The element selector in jQuery is used to select all elements with the specific element name.
Syntax
The syntax is as follows −
$("ele")
Above, ele is the element to select.
Example
Let us now see an example to implement the jQuery element 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(){ $("button").click(function(){ $("h2").css("color", "orange"); }); }); </script> </head> <body> <h2>Student Info</h2> <p>This is a demo text.</p> <h2>Exam Info</h2> <p>This is a demo text.</p> <h2>Teacher's Info</h2> <p>This is a demo text.</p> <button>Click me</button> </body> </html>
Output
This will produce the following output −
Above, click the button “Click me” to update heading color −
- Related Articles
- jQuery element ~ siblings Selector
- jQuery element + next Selector
- How to get a DOM Element from a jQuery Selector?
- How to exclude first and second element from jQuery selector?
- jQuery :button Selector
- jQuery :checkbox Selector
- jQuery :checked Selector
- jQuery :contains() Selector
- jQuery :disabled Selector
- jQuery :empty Selector
- jQuery :enabled Selector
- jQuery :even Selector
- jQuery :file Selector
- jQuery :first Selector
- jQuery :focus Selector

Advertisements