I'm trying to improve the following code (for a button counter), but I'm unsure on initial inspection.
document.querySelectorAll("#minus")[0].addEventListener("click", function(e){
e.stopPropagation();
document.querySelectorAll("#number")[0].innerText = Number(document.querySelectorAll("#number")[0].innerText) - 1
})
document.querySelectorAll("#plus")[0].addEventListener("click", function(e) {
e.stopPropagation();
document.querySelectorAll("#number")[0].innerText = Number(document.querySelectorAll("#number")[0].innerText) + 1
})
How would I make this code more efficient?
I'm also looking to add a rule where the counter cannot reach zero.
Thankyou kindly for any help :)