I'm trying to add a Class to each anchor inside #somecontainer
whose children have .someclass
For example.
<div id="container">
<a><span class="someclass"></span></a>
<a></a>
<a><span class="someclass">/span></a>
</div>
In the above code i want the first and third anchors to have a class '.anotherclass' I tried this code but it doesn't seem to work
jQuery('#container a').each(function(){
jQuery(this).has('.someclass').addClass('anotherclass');
})
Update:
.has()
returns aboolean
and not jQuery object. That's why the code didn't work