1

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?

Cedric Martens
  • 1,139
  • 10
  • 23

1 Answers1

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