There is such a html:

<div class="input-group quantity_goods"> <input type="number" step="1" min="1" max="10" id="num_count" name="quantity" value="1" title="Qty"> <input type="button" value="-" id="button_minus"> <input type="button" value="+" id="button_plus"> </div> 

How to activate + - in the quantity field?

    1 answer 1

     var numCount = document.getElementById('num_count'); var plusBtn = document.getElementById('button_plus'); var minusBtn = document.getElementById('button_minus'); plusBtn.onclick = function() { var qty = parseInt(numCount.value); qty = qty + 1; numCount.value = qty; } minusBtn.onclick = function() { var qty = parseInt(numCount.value); qty = qty - 1; numCount.value = qty; } 
     <div class="input-group quantity_goods"> <input type="number" step="1" min="1" max="10" id="num_count" name="quantity" value="1" title="Qty"> <input type="button" value="-" id="button_minus"> <input type="button" value="+" id="button_plus"> </div> 

    • and when the unit, will also take away the amount? )) - Sergey V.