I am looking to use jQuery
to view a bunch of <div>
elements which all have the same class name, and check to see if the h3
within these <div>
elements has any content. I was thinking this would work (as below) but its not... what am I doing wrong?
$('.wrapperDIV').each(function (i) {
if( $(this).closest('h3').val().length == 0 ) {
$(this).addClass('.hideME');
}
});
Markup is:
<div class="wrapperDIV">
<span class="ItemNo">5.</span>
<a href="#" title="Read more about "><img src="" title="" alt=""></a>
<h3></h3>
<div class="composer-button">
<a href="#" class="read-more" title="Read more about ">Read more</a>
</div>
</div>