let minusBtn = document.getElementById("minus"); let count = document.getElementById("quantity"); let plusBtn = document.getElementById("plus"); let countNum = 1; count.innerHTML = countNum; minusBtn.addEventListener("click", () => { if(count.value >= 1){ countNum -= 1; count.value = countNum; }else{ return } }); plusBtn.addEventListener("click", () => { countNum += 1; count.value = countNum; });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter