Reputation: 37633
How to use part of the Id or Class of DOM element with jQuery selector?
I.e. We have
id="Some_Extra_Name"
Can we use "Extra" to get all elements with jQuery?
Upvotes: 0
Views: 68
Reputation: 382150
Yes, you can do
$elements = $('[id*=Extra]');
If you wanted to get the elements whose id starts with "Extra"
, you'd do
$elements = $('[id^=Extra]');
and for the elements whose id ends with "Extra"
:
$elements = $('[id$=Extra]');
Upvotes: 4