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