add a div.class in a child, only when the parent does not have other div.class
- by armandfp
i have a html code like this:
<div class="someclass">
<div class="childclass"></div>
<div class="checkclass"></div>
</div>
<div class="someclass">
<div class="childclass"></div>
</div>
<div class="someclass">
<div class="childclass"></div>
<div class="checkclass"></div>
</div>
<div class="someclass">
<div class="childclass"></div>
<div class="checkclass"></div>
</div>
<div class="someclass">
<div class="childclass"></div>
</div>
and i need to add a div only on those divs that dont have that "checkclass", so it will like this:
<div class="someclass">
<div class="childclass"></div>
<div class="checkclass"></div>
</div>
<div class="someclass">
<div class="childclass"></div>
<div class="newclass"></div>
</div>
<div class="someclass">
<div class="childclass"></div>
<div class="checkclass"></div>
</div>
<div class="someclass">
<div class="childclass"></div>
<div class="checkclass"></div>
</div>
<div class="someclass">
<div class="childclass"></div>
<div class="newclass"></div>
</div>
i tried with jquery something like:
$('.someclase:not(children(hasClass(checkclass))').append('<div class="newclass"></div>');
$('.someclass:not(:children(.checkclass))').append('<div class="newclass"></div>');
$('.someclass > :not(.checkclass)').append('<div class="newclass"></div>');
but still nothing, any ideas?