I have a wrapper that shows an image and a star. I want to hide the wrapper if both image and star has a class named "no". It has to be both, if just only one of them has the "no" class it has to be shown.
<div id="wrapper">
<a href="#" class="image no" target="_blank"><img src="something.jpg"></a>
<a href="#" class="star no"><img src="star.png"></a>
</div>
Something like this:
if ($(".image, .no") && $(".star, .no")) {
document.getElementById("wrapper").style.display = "none";
}
.hasClass() is what you looking for
if ($(".image").hasClass("no") && $(".star").hasClass("no")) {
// TODO
}
Even simpler
if ($(".image,.star").is(".no")){
// TODO
}
You can also do it without jQuery:
if(document.querySelectorAll('.image.no').length && document.querySelectorAll('.star.no').length) {
document.getElementById("wrapper").style.display = "none";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With