So, if you search through the .mini-product
for the .product-number
then when you hit the right number you can search the .mini-product
again for the .checkout-spacing
and hide them.
$(document).ready(function(){
const comparingText = '215365';
$('.mini-product').each((index, mp) =>
{
let productNumber = $(mp).find('.product-number').first().text().trim();
if(productNumber == comparingText)
{
$(mp).find('.checkout-spacing').each((csi, cs)=>
{
$(cs).css('display', 'none');
});
}
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="mini-product ">
<div class="mini-product-content">
<div class="row-flex mini-product-content-wrapper">
<div class="col any-1-1">
<div class="product-in-stock--mobile"><span class="items-in-stock">
<span class="checkout-spacing">På nettlager (100+)</span>
</span>
<span class="store-stock"></span>
</div>
</div>
<div class="col col-infos any-1-1">
<div class="product-number sku rsNoDrag">215365</div>
</div>
</div>
<div class="row-flex on-hover">
<div class="product-info-wrap">
<div class="product-in-stock product-in-stock--desktop">
<span class="items-in-stock">
<span class="checkout-spacing">På nettlager (100+)</span>
</span>
</div>
</div>
</div>
</div>
</div>
If you want to have multiple numbers to search for, create an array and use includes
:
//instead of const comparingText = '215365';
const numbersToCheck = ['215365', '4400', '42'];
//instead of if(productNumber == comparingText)
if(numbersToCheck.includes(productNumber))
{
}
CLICK HERE to find out more related problems solutions.