Reputation: 2341
I have a div with many many html elements like other divs, trs, tds, tables etc
Is it possible to get all the elements which have an id?
I know asking $("#test")
will give me the specific element with this id
but is it possible to get find("#")
or something like this?!
Upvotes: 18
Views: 16651
Reputation: 10015
You can use the following syntax to limit the results:
$('input[id*=test_id]').live('click', callbackFunc());
or
$('.elements_set[id*=test_id]').live('click', callbackFunc());
or in same manner
$('input[name*=test_id]').live('click', callbackFunc());
These are called Attribute Selectors
Reference links:
Upvotes: 4
Reputation: 5403
You should look into documentation on their selectors. This will show you exactly what to do in any situation when you are selecting something.
Also note that you can use more than one selector at a time, like their example:
$("div,span,p.myClass").css("border","3px solid red");
Upvotes: 0