fire matter when the value changes? It's just interesting if anyone knows what events the HTML5 elemen...">

What events does <input type = "number" / "> fire matter when the value changes?

It's just interesting if anyone knows what events the HTML5 element <input type="number" /> triggers when the up / down arrows are pressed:

example number input

I already use onblur when the focus leaves the input field.

+62
javascript html5
Oct. 15 '10 at 7:26
source share
4 answers

change will be the event that will be fired when the field value changes.

I think the HTML5 input event also fires.

+48
Oct. 15 '10 at 7:30
source share

I found that for jQuery the following code covers keyboard input, mouse changes and button clicks in Chrome, and also handles keyboard input in Firefox

 $("input[type=number]").bind('keyup input', function(){ // handle event }); 
+25
Apr 09 '13 at
source share

I found that onkeyup and onchange encompass everything in Chrome 19. This handles direct input of a value, a down arrow, button clicks, and a mouse wheel scroll.

onchange will suffice in Chrome, but other browsers that only display the field as a text field need an onkeyup binding that works onkeyup fine to read the new value.

mousewheel event mousewheel individually was less successful. The event was fired too early - before the field value was updated - and therefore always gave the field the previous value

+4
May 24 '12 at 12:42
source share

The onchange event fires on blur, but the oninput event fires on input. Perhaps you want to set a timer for the oninput event and fire your onchange event when the user stops printing for a second?

+3
Oct. 15 '10 at 7:50
source share



All Articles