- 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 use OR Operation in jQuery Attribute Selectors?
Use comma to work with OR operation in jQuery Attribute Selector.
Example
You can try to run the following code to learn how to use OR operation in jQuery attribute selector:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('[myattr=demo][myid="sub1"],[myattr=demo][myid="sub3"]').css("background-color", "yellow"); }); </script> </head> <body> <div myid="sub1" myattr="demo">Java</div> <div myid="sub2" myattr="demo">HTML</div> <div myid="sub3" myattr="demo">Ruby</div> </body> </html>
- Related Articles
- How to use JavaScript variables in jQuery selectors?
- How to use *= operator in jQuery attribute selector?
- How to use input readonly attribute in jQuery?
- How to use jQuery selectors on custom data attributes using HTML5?
- Attribute Selectors in CSS
- How to use wildcards like $ ('#name*'), $ ('#name%') in jQuery selectors?
- How do we use # in jQuery Attribute Selector?
- How does CSS Selectors work in jQuery?
- What are jQuery Selectors?
- How to get value of data attribute and use it in jQuery?
- Styling Forms with CSS Attribute Selectors
- How to use attr() method in jQuery to get the value of an attribute?
- How do we use jQuery Attribute selector with a period?
- How to use jQuery to get the value of HTML attribute of elements?
- How to use CSS Selectors for styling elements?

Advertisements