I have several divs in my site, where they contain the following class "code $ numb" where $ numb is a random number, how can I capture all the divs with the code regardless of $ numb?
I have several divs in my site, where they contain the following class "code $ numb" where $ numb is a random number, how can I capture all the divs with the code regardless of $ numb?
How to utluiz referred in this case may be more create a class to group these elements and save this $numb
otherwise ( data-
field for example).
But to answer your question about capturing all elements with code, regardless of $numb
, you can use this:
$('div[class^="code"]');
where ^=
means starting at ...
You can read more about this selector here , but what says in the description is:
Choose elements that have a specific attribute starting exactly with the specified string