Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

monitoring type=number?

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

  • because in browsers that support it It gets spin controls I can't just monitor .keyup,
  • because I don't want to wait for it to lose focus I can't just monitor .change.

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

like image 978
Hailwood Avatar asked Mar 01 '26 07:03

Hailwood


1 Answers

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?
like image 71
Hailwood Avatar answered Mar 03 '26 21:03

Hailwood



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!