I am trying to find the JQuery event that fires when you hold the up or down buttons on an input of type number. The change
event fires once you release the button, but it does not fire progressively as you hold it. What event should I use if I want it to fire every time the number changes in the input?
Asked
Active
Viewed 26 times
1

Cedric Martens
- 1,139
- 10
- 23
-
https://stackoverflow.com/questions/9609731/onchange-event-for-input-type-number 2nd answer. it seems that .on('input') does what you want – Pierre Emmanuel Lallemant Aug 24 '19 at 22:53
1 Answers
1
Using 'input'
Event
$('[type="number"]').on('input', function(e) {
console.log(e.type)
})
Use keyboard arrows or Input's UI arrows:<br>
<input type="number" name="">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
'keypress'
Event works only on type=text
$('input').on('keypress', function(e) {
console.log(e.type)
})
<input type="text" name="" value="text type">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Roko C. Buljan
- 196,159
- 39
- 305
- 313