I’m triying to add a class to a child but only on children containing a specific class
This is an example of the existing HTML:
<div class="iteration-Odd">
<div class="style1"></div>
<div class="style2"></div>
</div>
And I need to add an additional class to the div with "style2"
Tried this with no luck:
$('.iteration-Odd').find('.style2').addClass('.new-class');
4
Answers
Please check this,
you need to replace
O
too
Another way you can do with
Parent Child
jquery selector
like.iteration-odd > .style2
here you don’t need to usefind
methodFor More detail check this link -> Click Me