practice-time-shopping-list.../scripts/app.js

36 lines
1.1 KiB
JavaScript

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 () {
}
})