Hailwood
Hailwood

Reputation: 92581

monitoring type=number?

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

How can I monitor it so I catch all cases where it's value is changed?

Upvotes: 3

Views: 721

Answers (2)

Hailwood
Hailwood

Reputation: 92581

After looking at some of the question's on this site and using the mousewheel plugin I have got

$('#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 monitor it for

  • Click: clicking on the controls
  • change: fallback
  • keyup: for entering a value
  • mousewheel: hmmm... I wonder?

Upvotes: 1

Ry-
Ry-

Reputation: 224857

See: HTML5 number spinbox controls not triggering a change event?

You might use both oninput and onkeydown for compatibility.

Upvotes: 0

Related Questions