I'm new to JQuery please help. I need to select multiple elements knowing only part of Id: eg:
<div id="element32422455">Some content</div>
<div id="element68475124">Some content</div>
<div id="element42352355">Some content</div>
Is is possible to select those elements using staff like this
$('#element*');
If you know any other good way to do it, please tell.
You can do it by using attribute starts with selector
,
var elems = $('[id^=element]');
There is no need to use wild card selector at this context, it is actually called attribute contains selector
. And that will select the element though it has id like "123213element12312"
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