- 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 jQuery selectors on custom data attributes using HTML5?
To use jQuery selectors on custom data attributes, you can use contains, starts with, and ends with for the HTML data attributes.
Example
Other than that, you can try to run the following code to learn how to use jQuery selectors on custom data attributes using HTML5:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ //stored selector var group = $('ol[data-group="Subjects"]'); // starts with M var maths = $('[data-subject^="M"]',group).css('color','green'); // contains the string graph var graph = $('[data-subject*="graph"]',group).css('color','blue'); }); </script> </head> <body> <ol data-group="Subjects"> <li data-subject="Maths">Maths</li> <li data-subject="Science">Science</li> <li data-subject="Geography">Geography</li> <li data-subject="History">History</li> </ol> </body> </html>
- Related Articles
- Creating custom attributes with HTML5
- How to use JavaScript variables in jQuery selectors?
- How to use OR Operation in jQuery Attribute Selectors?
- How do we embed custom data attributes on all HTML elements?
- Store and retrieve arrays into and from HTML5 data attributes with jQuery?
- How to remove all style attributes using jQuery?
- How to filter object array based on attributes in jQuery?
- How to construct custom attributes in C#?
- How to create custom attributes in C#?
- How to use wildcards like $ ('#name*'), $ ('#name%') in jQuery selectors?
- How to handle HTML5 media events using jQuery?
- What are jQuery Selectors?
- How does CSS Selectors work in jQuery?
- Using Data-Attributes (data-*) in CSS
- HTML5 Microdata Attributes

Advertisements