- 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
How to combine a class selector and an attribute selector with jQuery?
A jQuery Selector is a function which makes use of expressions to find out matching elements from a DOM based on the given criteria. We can easily combine a class selector and an attribute selector with jQuery.
You can try to run the following code to learn how to How to combine a class selector and an attribute selector with jQuery −
Example
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $('.myclass[reference="12345"]').css("background-color", "yellow"); }); </script> </head> <body> <table> <tr class="myclass" reference="12345"> <td>Row 1 Column 1</td> </tr> <tr class="myclass" reference="43215"> <td>Row 2 Column 1</td> </tr> <tr class="myclass" reference="54321"> <td>Row 3 Column 1</td> </tr> </table> </body> </html>
- Related Articles
- jQuery [attribute!=value] Selector
- jQuery .class Selector
- How do we use jQuery Attribute selector with a period?
- How to make jQuery attribute selector case insensitive?
- How to use *= operator in jQuery attribute selector?
- How to write a jQuery selector to find links with # in href attribute?
- How do we use # in jQuery Attribute Selector?
- How to pass a variable into a jQuery attribute-contains selector?
- jQuery :has() Selector with example
- What is the difference between jQuery(selector) and $(selector)?
- jQuery :button Selector
- jQuery :checkbox Selector
- jQuery :checked Selector
- jQuery :contains() Selector
- jQuery :disabled Selector

Advertisements