Lets say we have this code:
<div id='m1'>
<div class="c"></div>
<div class="c"></div>
<div class="c"></div>
</div>
<div id='m2'>
<div class="c"></div>
<div class="c"></div>
<div class="c"></div>
</div>
How can i get divs with class ‘c’ that are in div with id ‘m1’? And then set them some css settings…
This will apply the properties to all
class="c"divs within adivwhich itself hasid="m1".If you’re asking for how to get them with Javascript, you can use any library that bundles a CSS-type selector library (like Sizzle!) to do this easily.
For example, in JQuery:
Or in Dojo: