[ACCEPTED]-Check if the content of a DIV is empty in jQuery-size

Accepted answer
Score: 24

If you mean really empty, use the empty-selector[docs] :

alert( !!$("#unframed-items:empty").length )

or

alert( $("#unframed-items").is(':empty') )

If 2 you consider whitespace-only to be empty, then 1 use the jQuery.trim()[docs] method:

alert( !$.trim( $("#unframed-items").html() ) );
Score: 0
<div id="portfolio"><!--portfolio-->
<div id="portfolio-works"><!--portfolio-works-->
    <div class="portfolio-works-container"></div>
</div><!--/portfolio-works-->

 $(document).ready(function(){
    if($('div.portfolio-works-container').is(':empty')){
        $('div#portfolio').hide();
    }
});

0

More Related questions