2022-11-12 21:29:34 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', function(){
|
|
|
|
const quantityInput = document.querySelector('.shopping-form-quantity-input');
|
|
|
|
|
|
|
|
const increment = document.querySelector('.shopping-form-increment-button');
|
|
|
|
const decrement = document.querySelector('.shopping-form-decrement-button');
|
|
|
|
const textValue = document.querySelector('.shopping-form-submit-button');
|
|
|
|
|
|
|
|
increment.addEventListener('click', addIcrement)
|
|
|
|
decrement.addEventListener('click', addDecrement)
|
|
|
|
textValue.addEventListener('click', addTextValue)
|
|
|
|
|
|
|
|
function addIcrement() {
|
|
|
|
const valueQuantityInput = Number(quantityInput.value);
|
|
|
|
const newValue = valueQuantityInput + 1;
|
|
|
|
|
|
|
|
quantityInput.value = newValue;
|
|
|
|
}
|
|
|
|
function addDecrement() {
|
|
|
|
const valueQuantityInput = Number(quantityInput.value);
|
|
|
|
const newValue = valueQuantityInput - 1;
|
|
|
|
if(newValue > 0) {
|
|
|
|
quantityInput.value = newValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const li = createElement('li');
|
|
|
|
|
|
|
|
|
|
|
|
function addTextValue () {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|