Reputation: 337
What event should I use to get an input number value where the value is changed typing or changed with button,
<p><input id="multiplier" type="number"></p>
change
doesn't work when types only using the buttons
$('#multiplier').change(function(){
var value = $(this).val();
});
Upvotes: 2
Views: 1589
Reputation: 5121
You can combine two event triggers like this:
$('#multiplier').on('keyup change', function(){
var value = $(this).val();
console.log(value)
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p><input id="multiplier" type="number"></p>
Upvotes: 1
Reputation: 36
let multiplier = document.getElementById("multiplier");
multiplier.addEventListener("input",function(){
let value = this.value;
console.log(value)
})
<p><input id="multiplier" type="number"></p>
Upvotes: 2