Answer the question
In order to leave comments, you need to log in
Is it possible to change the class of the button and its name through (if else)?
Good morning everyone.
need a little help.
There are two blocks on the page.
<div class="single-goods">
<p class="soh-goods">на складе</p>
<button class="add-to-cart">Купить</button>
</div>
<div class="single-goods">
<p class="soh-goods">нет на складе</p>
<button class="add-to-cart">Купить</button>
</div>
Answer the question
In order to leave comments, you need to log in
$(document).ready(function(){
$('.soh-goods').each(function(){
if ($(this).html() == 'нет на складе') {
$(this).closest('.single-goods').find('.add-to-cart').removeClass('add-to-cart').addClass('add-to-soh').html('Заказать');
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question