Type of monitoring = number?

I am using html5 input type="number". I want to control this input for a change, but:

  • because in browsers that support it, it gets back control, I can’t just control it .keyup,
  • because I don’t want to wait until he loses focus. I can’t just control it .change.

How can I control it, so I catch all the cases when this value changes?

+3
source share
2 answers

Having looked at some question on this site and using the mousewheel plugin , I have

$('#spinbox').bind('click change keyup mousewheel', function() {
  //10 ms timeout is for mousewheel otherwise you get the previous value
  var box = this;
  setTimeout(function() {console.log($(box).val());}, 10);
});

So you need to track it for

  • Click: by clicking on the controls
  • change: fallback
  • keyup: to enter a value
  • mousewheel: hmmm... ?
+1

: HTML5 ?

oninput, onkeydown.

0

All Articles