javascript - 立即检测更改事件

标签 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/

相关文章:

javascript - Jquery 移动幻灯片

javascript - Google map API 地理编码 - 附加参数

javascript - 使用其他数组对对象数组进行排序

javascript - 如何在 jQuery Ajax 成功回调中处理我的 JSON 数据?

javascript - 表单正在重置页面而不是显示文本

javascript - 视点参数关闭标签问题

javascript - 一键添加表格中的选择和选项

javascript - 事件处理程序在外​​部 JS 文件中不起作用?

javascript - 通过 Angular 建立到页面的外部链接 - 我无法转到外部页面

javascript - 如何让这个 float 图标下降并保持粘性