I am using the following snippet to update the value of my number input field:
<div class="number-input">
<button
type="button"
onclick="this.parentNode.querySelector('input[type=number').stepDown()"
style="border-right: 0.1px solid #555555"
></button>
<input
class="quantity tank"
min="0"
name="soldier"
value="0"
type="number"
max="10"
/>
<button
type="button"
onclick="this.parentNode.querySelector('input[type=number').stepUp()"
style="border-left: 0.1px solid #555555"
class="plus"
></button>
</div>
However, when I use stepUp and stepDown with a number input, its value does not get updated in the DOM :
The Problem
I want to get the value of this input field everytime it is updated (an alert or just log it to the console) but am not able to start doing so because of this, is there a workaround to this or some way I can still access the value of the input field on update?
$(".soldier").bind("keyup", function () {
console.log($(".soldier").val());
});
This was one of the solutions I found but it only works when the user focuses and presses a key inside the input field, whereas I am updating the field with two other buttons.