Get all divs with jquery

1

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?     

asked by anonymous 08.07.2014 / 22:51

1 answer

5

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

Example: link

    
08.07.2014 / 23:03