在看到这个 jsfiddle 之前,我从未听说过 jQuery 中名为 input 的事件.
I've never heard of an event in jQuery called input till I saw this jsfiddle.
你知道它为什么有效吗?它是 keyup 的别名还是什么?
Do you know why it's working? Is it an alias for keyup or something?
$(document).on('input', 'input:text', function() {}); 推荐答案在通过用户界面更改元素的文本内容时发生.
Occurs when the text content of an element is changed through the user interface.
它不是 keyup 的别名,因为即使键什么都不做,keyup 也会触发(例如:按下然后松开 Control 键会触发一个 keyup 事件).
It's not quite an alias for keyup because keyup will fire even if the key does nothing (for example: pressing and then releasing the Control key will trigger a keyup event).
一个很好的思考方式是这样的:它是一个每当输入改变时触发的事件.这包括 -- 但不限于 -- 按下修改输入的键(例如,Ctrl 本身不会触发事件,但 Ctrl-V粘贴一些文本)、选择自动完成选项、Linux 风格的中键粘贴、拖放和许多其他操作.
A good way to think about it is like this: it's an event that triggers whenever the input changes. This includes -- but is not limited to -- pressing keys which modify the input (so, for example, Ctrl by itself will not trigger the event, but Ctrl-V to paste some text will), selecting an auto-completion option, Linux-style middle-click paste, drag-and-drop, and lots of other things.
有关详细信息,请参阅此页面和对此答案的评论.
See this page and the comments on this answer for more details.
更多推荐
jQuery“输入"事件
发布评论