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();
});
let multiplier = document.getElementById("multiplier"); multiplier.addEventListener("input",function(){ let value = this.value; console.log(value) })
<p><input id="multiplier" type="number"></p>
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.