2011-05-06 41 views
3

我使用html5輸入type="number"。我想監視此輸入的變化,但:monitoring type = number?

  • ,因爲支持它的瀏覽器中它得到自旋的控制,我不能只監測.keyup
  • ,因爲我不想等待它輸重點我不能只監視.change

我該如何監控它,以便捕獲價值發生變化的所有情況?

+0

[HTML5事件偵聽器的數字輸入滾動可能重複 - 僅限Chrome](http://stackoverflow.com/questions/5669207/html5-event-listener-for-number-input-scroll-chrome-only) – 2011-05-06 00:54:16

回答

1

看一些問題後對本網站和使用mousewheel plugin我有

$('#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); 
}); 

所以,你需要監視它

  • 點擊:點擊控件
  • 變化:fallback
  • keyup:輸入數值
  • mousewheel:嗯......我想知道?
相關問題