I am working on a website in which I want to check whether element has any content in it.
Below is my html code. I have mentioned condition#1 where
You can loop over parent div and find the child items and then add the class over there.
Here in the example, I am getting $('.featured-block__item-inner')
as a parent and then finding items inside it.
$('.featured-block__item-inner').each(function() {
if ($(this).find(".featured-block__title").not(":empty").length > 0 && $(this).find(".featured-block__tag").not(":empty").length > 0) {
$(this).find(".img-fit img").addClass("opacity-pointseven"); // For condition#1
} else {
$(this).find(".img-fit img").addClass("default-opacity");
}
})
.opacity-pointseven {
width: 100px;
height: 100px;
}
.default-opacity {
width: 50px;
height: 50px;
}