I need to add a class to a parent div if one of the children elements contains the word "Sponsored."
<div id="post-item">
<span class="tags">
<a href="#">Blogs</a>
</span>
</div>
<div id="post-item">
<span class="tags">
<a href="#">Sponsored by Lorem Ipsum</a>
</span>
</div>
I am currently trying to use parent().addClass but it's not working for some reason. You can see an example in this fiddle: http://jsfiddle.net/VrPdF/
if (jQuery('a:contains("Sponsored")').length) {
jQuery(this).parent('#post-item').addClass('sponz');
}
Any and all help would be greatly appreciated - thanks !
