<div class="form-group">
<div class="input-group number-spinner">
<span class="input-group-btn">
<button class="btn" data-dir="dwn">
<i class="fa fa-minus"></i>
</button>
</span>
<input type="text" name="quantity" value="{{ minimum }}" id="input-quantity" class="form-control text-center" />
<span class="input-group-btn">
<button class="btn" data-dir="up">
<i class="fa fa-plus"></i>
</button>
</span>
</div>
</div>
</div>
$(document).on('click', '.number-spinner button', function () { var btn = $(this), oldValue = btn.closest('.number-spinner').find('input').val().trim(), newVal = 1; if (btn.attr('data-dir') == 'up') { newVal = parseInt(oldValue) + 1; } else { if (oldValue > 1) { newVal = parseInt(oldValue) - 1; } else { newVal = 1; } } btn.closest('.number-spinner').find('input').val(newVal); });
});