let calc = document.querySelectorAll('.controle-ajuste');
let count = document.querySelectorAll('.controle-contador')
calc.forEach((element) => {
element.addEventListener('click', (evento) => {
operation(evento.target.textContent, evento.target)
})
})
function operation(typeOfOperation, count) {
if (typeOfOperation == '+') {
count.previousElementSibling.value = Number(count.previousElementSibling.value) + 1
} else {
if (count.nextElementSibling.value > 0) {
count.nextElementSibling.value = Number(count.nextElementSibling.value) - 1
}
}
}
meu código ficou assim, ficou diferente porque eu fiz antes, mas funcionou :)