Linked Questions
86 questions linked to/from How to use a regular expression in a jQuery selector?
6 votes
4 answers
1k views
How to accept any characters in between * of an getElementById (stack_ * _overflow)? [duplicate]
I have a page which changes the ID of input fields every time. So for example if I visit the page now, the ID can be "stack_15_overflow" and next time it can be "stack_293_overflow". I want to use a ...
2 votes
2 answers
362 views
jQuery Get all elements where class contains a number [duplicate]
I want to get all elements that class contains a number, how can I do that? I haven't tried anything because I don't really know how to think about it.
5 votes
2 answers
294 views
Can we use a regex with a common jquery query? [duplicate]
I would like to affect all my elements containing a class almost similar, i could iterate and use the iterator to do the job, but i am wondering if we could use a regex in this case: $('.player')....
2 votes
2 answers
72 views
Wildcad selector with ignoring similar matches [duplicate]
So i want to hide all elements and use $('[id^=option_]').hide(); And that works fine, however it is hiding things i dont want it to hide. I have dynamically generated ids such as option_1 ...
0 votes
0 answers
48 views
How to apply range of values to a partial attribute selector? [duplicate]
I would like to apply a numeric range on ends with (id$=) with jQuery but I couldn't. I tried: [id$="[1-8]"] My code: <script> $(function() { $('[id^="text"][id$="[...
0 votes
0 answers
40 views
Jquery match element with matching pattern id [duplicate]
I have an element with id shipping_method_0_some_name_here. The element will always have this pattern, only the number in the middle will differantiate, and there will always be only one element like ...
1976 votes
29 answers
1.4m views
How do you use a variable in a regular expression?
I would like to create a String.replaceAll() method in JavaScript and think using a regex would be the most terse way to do it. However, I can't figure out how to pass a variable into a regex. I can ...
745 votes
6 answers
562k views
Wildcards in jQuery selectors
I'm trying to use a wildcard to get the id of all the elements whose id begin with "jander". I tried $('#jander*'), $('#jander%') but it doesn't work.. I know I can use classes of the elements to ...
169 votes
4 answers
258k views
Find all elements on a page whose element ID contains a certain text using jQuery
I'm trying to find all elements on a page whose element ID contains a certain text. I'll then need to filter the found elements based on whether they are hidden or not. Any help is greatly appreciated....
62 votes
7 answers
89k views
How can I select an element by ID with jQuery using regex?
I have the following input elements: <input id="AAA_RandomString_BBB" type="text" /> <input id="AAA_RandomString_BBB_Start" type="text" /> <input id="AAA_RandomString_BBB_End" type="...
56 votes
4 answers
97k views
JQuery, how to find list of div's with similar ID
I have a structure of html like this: <div id="triger1">some elements inside</div> <div id="triger2">some elements inside</div> <div id="triger3&...
21 votes
7 answers
33k views
jQuery - Get a element class based on a prefix
What's the fastest way possible to get a string like "fade" from the classes in the element below? <div class="MyElement fx-fade"> ... </div>
36 votes
6 answers
39k views
jQuery match part of class with hasClass
I have several div's with "project[0-9]" classes: <div class="project1"></div> <div class="project2"></div> <div class="project3"></div> <div class="project4"&...
19 votes
3 answers
53k views
How do you select all id tags that contain a certain string in javascript?
I have an ASP.NET application that renders multiple questions with the option to provide an explanation for the answers given. <label for="[<%:count %>].AnswerExplanation_<%: i+1 %>" ...
16 votes
2 answers
33k views
jquery: click for every id-element starting with
I tried to find all ids starting with the string "matchItem_" and define a click-event for each. onclick i want wo execute a script with a URL parameter and change the image in this id-...