Select div (or other element) that class contains "grap" (o other specified word) for example

born2fr4g picture born2fr4g · Sep 11, 2011 · Viewed 38.4k times · Source

First of all; example of HTML code:

<div class"grap1"> some conetent</div>
<div class"grap2"> some conetent</div>
<div class"grap3"> some conetent</div>
<div class"blabla">some content></div>

And now i want to select divs that class contains "grap" word somewhere is class name (so in this case first three divs). How can i achieve that ?

This is not working: http://api.jquery.com/attribute-contains-word-selector/

Answer

Andrei picture Andrei · Sep 11, 2011

Use the attribute contains selector:

$('div[class*="grap"]')