- 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 wildcards like $ ('#name*'), $ ('#name%') in jQuery selectors?
For getting the id that begins or ends with a particular string in jQuery selectors, you shouldn’t use the wildcards $('#name*'), $('#name%'). Instead use the characters ^and $. The ^ is used is used to get all elements starting with a particular string. The $ is used is used to get all elements ending with a particular string.
Example
You can try to run the following code to learn how to get id beginning and endingwith a particular string.
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("[id$=new1]").css("background-color", "yellow"); $("[id^=myid]").css("background-color", "green"); }); </script> </head> <body> <div id="idnew1" myattr="javasubject">Java</div> <div id="idnew2" myattr="htmlsubject">HTML</div> <div id="myid1" myattr="rubysubject">Ruby</div> <div id="myid2" myattr="cppsubject">C++</div> </body> </html>
- Related Articles
- How to get all collections where collection name like '%2015%'?
- How can I use 'Not Like' operator in MongoDB?
- How to Use 'U' and 'L' formatters in Arduino?
- How to make 'from' as column name in MySQL?
- How to properly use 'exist' function in MongoDB like in SQL?
- How to use the 'break' and 'next' statements in Ruby?
- How to use 'extent' in matplotlib.pyplot.imshow?
- JavaScript How to get all 'name' values in a JSON array?
- How to use 'const' keyword in JavaScript?
- How to DROP a database in MySQL with character '?' in its name?
- MySQL query to select ENUM('M', 'F') as 'Male' or 'Female'?
- How to use the 'with' keyword in JavaScript?
- How to use the 'and' keyword in Ruby?
- Finding the sum of two numbers without using '+', '-', '/', '*' in JavaScript
- How does $('iframe').ready() method work in jQuery?

Advertisements