<分区>
Possible Duplicate:
How to detect textbox change event from javascript
如何在插入后立即检测到文本字段的插入值? change
事件仅在失去焦点后才会出现,keyPress、keyUp、keyDown
等对我没有帮助,因为新值是从条形码扫描仪插入的(它不会上升)键盘事件)。只使用定时器并定期检查文本字段中的值?
标签 javascript
<分区>
Possible Duplicate:
How to detect textbox change event from javascript
如何在插入后立即检测到文本字段的插入值? change
事件仅在失去焦点后才会出现,keyPress、keyUp、keyDown
等对我没有帮助,因为新值是从条形码扫描仪插入的(它不会上升)键盘事件)。只使用定时器并定期检查文本字段中的值?
最佳答案
您可以使用oninput
事件。只要在该字段中进行输入,它就会触发。
有关更多信息,我将从这个博客中获取报价:http://whattheheadsaid.com/2010/09/effectively-detecting-user-input-in-javascript (作者 @AndyE )
Talking about onkeydown and timers...
However, this still doesn’t deal with input that doesn’t involve a keyboard. What other types of input? How about context menu actions; cut, paste, undo and redo? Drag and drop? There have been events to handle some other kinds of input change for a while – several browsers support the onpaste, oncut and oncopy events – but they’re non-standard and some vendors are just too stubborn to implement them.
Enter the HTML 5 event, oninput.
跨浏览器的jQuery插件,可以看看这个(同一作者):http://whattheheadsaid.com/projects/input-special-event
关于javascript - 立即检测更改事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11304645/