Hello, I’ve updated my code with new feature. Earlier if you click very quickly “+” button you can go beyond max. I fixed it.
function val_greater_max() {
$(‘.cart_item’).each(function () {
var max = $(this).find(‘input[type=”number”]’).attr(‘max’);
var val = $(this).find(‘input[type=”number”]’).val();
if (val === max || max < val ){ //NEW CHECK
$(this).find(‘.wac-qty-button .wac-btn-inc’).closest(‘.wac-qty-button’).css(‘display’,’none’);// new rules
$(this).find(“input[type=’number’]”).val(max);// Assign the value of the maximum number value
}
else {
$(this).find(‘.wac-qty-button .wac-btn-inc’).closest(‘.wac-qty-button’).css(‘display’,’block’);// new rules
}
});
}