I am trying to hide a class based on the display property of another class being set to inline-block !important
, using only JavaScript. Here is my current code snippet:
window.onload = function() {
hidedeliveryFunction() {
var outOfstock = document.getElementsByClassName(".action,.alert"),
deliveryOptions = document.getElementsByClassName(".shipping-product-info");
if (outOfstock.style.display === "inline-block !important") {
deliveryOptions.style.display = "none";
}
}
};
<!-- if this div has a display property of inline-block !important -->
<div class="product alert stock">
<a href="#" data-post="" title="Out of stock" class="action alert">Out of stock</a>
</div>
<!-- then hide this div by setting its display property to none -->
<div class="shipping-product-info">
<div class="ship-clickcollect option--available">
<div class="shipping-product-info--options">
<div class="shipping-product-info--icon"></div>
<div class="shipping-product-info--available"></div>
<div class="shipcontroller">
<p>Available on orders over $40. Collection in 1-7 days. WA orders 1-14 days. <a href="/click-and-collect"
target="_blank">More info »</a></p>
</div>
</div>
</div>
<div class="ship-homedelivery option--not-available">
<div class="shipping-product-info--options">
<div class="shipping-product-info--icon"></div>
<div class="shipping-product-info--available"></div>
<div class="shipcontroller">
<p>Free express shipping over $99. Some exclusions apply. <a href="/free-shipping-australia-wide">More info »</a></p>
</div>
</div>
</div>
</div>