Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

Find child H3 and check if has value

$
0
0

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>

Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>