javascript - 编辑仍在进行时更改文本框中的事件

标签 javascript jquery

威尔change jQuery中的事件可以用来监控<input />中的变化元素内容,只有在用户将焦点切换到其他位置后才会触发:

The change event is sent to an element when its value changes. This event is limited to elements, boxes and elements. For select boxes, checkboxes, and radio buttons, the event is fired immediately when the user makes a selection with the mouse, but for the other element types the event is deferred until the element loses focus.

当用户进行编辑但光标仍保留在文本框中时是否会触发事件?最好是 jQuery,但是本地浏览器事件甚至讨厌的解决方法都可以。

最佳答案

是的,在较新的浏览器中,input 事件会在所有输入上触发,否则会触发按键事件,

$('input[type="text"]').on('input', handler);
$('input[type="text"]').on('keyup', handler);
$('input[type="text"]').on('keydown', handler);
$('input[type="text"]').on('keypress', handler);
$('input[type="text"]').on('paste', handler);

input
keyup
keydown
keypress
paste

关于javascript - 编辑仍在进行时更改文本框中的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22015720/

相关文章:

javascript - AngularJS 多个指令 ngIf 要求在 !isFocused 上进行嵌入

javascript - 元素没有出现在包装器中,它们在下面

javascript - javascript 中的大于运算符在 xslt 中不起作用

javascript - jquery 中的 CSS 和 animate()

javascript - 基于 Node Webkit (nw.js) 的应用程序中没有输入验证

javascript - 从窗口外返回时出现模糊和焦点问题

javascript - 窗口大小已调整且文档准备就绪

javascript - 如何在 NodeJS/Javascript 中进行长轮询?

javascript - 如何使用 scss 根据隐藏属性更改样式?

javascript - 在javascript函数中返回具有十进制值的数组