I whant to add class on specific string but problem is that string starts with number 0.
This is my code I whant to add just on "0 BAM" class but when I add this Jquery he add class on all divs that have 0 and BAM, Like first one "290 BAM"
<div class="views-field-commerce-price"> 290 BAM</div>
<div class="views-field-commerce-price"> 0 BAM</div>
<div class="views-field-commerce-price"> 223 BAM</div>
<div class="views-field-commerce-price"> 490 BAM</div>
$('.views-field-commerce-price:contains("0 BAM")').addClass('item-3');
Thank You!
I think you need exact comparison, Here you can use .filter()
$('.views-field-commerce-price').filter(function(){
return $(this).text().trim() == "0 BAM";
}).addClass('item-3');
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