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?!
The CSS id Selector The id selector uses the id attribute of an HTML element to select a specific element. The id of an element is unique within a page, so the id selector is used to select one unique element! To select an element with a specific id, write a hash (#) character, followed by the id of the element.
The jQuery #id selector uses the id attribute of an HTML tag to find the specific element. An id should be unique within a page, so you should use the #id selector when you want to find a single, unique element.
The . class selector selects all elements with the specific class. The class refers to the class attribute of an HTML element.
$('[id]')
returns all elements that have id set
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With