Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140042

How to check empty div in Javascript/jQuery?

$
0
0

I have HTML code below in which I want to check empty div in javascript. If div.featured-block is empty then it should apply display: none on the house-senate class.

HTML Code:

<html class="js grunticon objectfit object-fit flexbox" lang="en-US">
<div class="focustop house-senate widget widget-cpac-depth -horizontal">
    <div class="featured-block">

    </div>
</div>
</html>

This is what I have tried but its not working.

jQuery code:

jQuery(function ($) {
    if ($(this).find("html:lang(en-US) .house-senate .featured-block").is(":empty")) {
        $(this).find(".house-senate").css("display", "none");   /* Display none */
    }
})

Problem Statement:

I am wondering what changes I should make in the jQuery code above so that it applies display:none on the house-senate class when div.featured-block is empty


Viewing all articles
Browse latest Browse all 140042

Trending Articles



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