I tried to make a code with Jquery when I click the + button, the field quantity increases, and when I press the – button the quantity decreases, and it works
but when I press another color and size, the field jumps no longer +1
do +2
However, this method still doesn’t work for me. Can anyone help? Thank you.
$('#partQuantity').on('click', "#plus" + data[k].Id, function(event) {
event.preventDefault();
var quantityInput = document.getElementById('qua' + data[k].SkuSizeId); // Assuming 'SkuSizeId' is the correct property
if (quantityInput) {
var currentValue = parseInt(quantityInput.value) || 1;
if (currentValue < data[k].OnHand) {
quantityInput.value = currentValue + 1;
}
}
});
$('#partQuantity').on('click', "#minus" + data[k].Id, function(event) {
event.preventDefault();
var quantityInput = document.getElementById('qua' + data[k].SkuSizeId); // Assuming 'SkuSizeId' is the correct property
var currentValue = parseInt(quantityInput.value);
if (currentValue > 1) {
quantityInput.value = currentValue - 1;
}
});