How to detect a textbox's content has changed

后端 未结 15 1891
猫巷女王i
猫巷女王i 2020-11-22 16:10

I want to detect whenever a textbox\'s content has changed. I can use the keyup method, but that will also detect keystrokes which do not generate letters, like the arrow ke

15条回答
  •  隐瞒了意图╮
    2020-11-22 16:27

    I'd like to ask why you are trying to detect when the content of the textbox changed in real time?

    An alternative would be to set a timer (via setIntval?) and compare last saved value to the current one and then reset a timer. This would guarantee catching ANY change, whether caused by keys, mouse, some other input device you didn't consider, or even JavaScript changing the value (another possiblity nobody mentioned) from a different part of the app.

提交回复
热议问题