I want to change the background of a div if the text from the closest element contains something. I realize that this probably is a duplicate but I simply can't find where it goes wrong. I'm not getting an error.
if (jQuery(".price-box").closest(".product").find(".product-title a").is(":contains('90')")) {
jQuery(this).closest(".product").find(".price-box").css('background-color', 'red');
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="product">
<div class="image-box">
<div class="price-box">Pricing</div>
</div>
<div class="box-text">
<div class="title-wrapper">
<p class="product-title">
<a href="#">Title 90</a>
</p>
</div>
</div>
</div>
If someone can enlighten me where my jQuery goes wrong I'd appreciate that alot.
Aucun commentaire:
Enregistrer un commentaire