Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

input with plus and minus buttons

<div>
  <input id="numberInput"/>
  <button id="plusButton">+</button>
  <button id="minusButton">-</button>
</div>
<script>
  textInput = document.querySelector('#numberInput');
  plusButton = document.querySelector('#plusButton');
  minusButton = document.querySelector('#minusButton');
  plusButton.onclick = () => textInput.value = parseInt(textInput.value) + 1;
  minusButton.onclick = () => textInput.value = parseInt(textInput.value) - 1;  
</script>
 
PREVIOUS NEXT
Tagged: #input #buttons
ADD COMMENT
Topic
Name
3+2 =