jQuery'input'事件 [英] jQuery 'input' event
问题描述
我从来没有听说过jQuery中的一个事件,叫做 input
直到我看到这个 jsfiddle 。
你知道为什么它的工作吗?是否为 keyup
或其他东西的别名?
$(document) .on('input','input:text',function(){});
元素的内容通过用户界面进行更改。
keyup
因为 keyup
将触发,即使该键不起作用(例如:按下然后释放控制键将触发 keyup
event)。
一个很好的方式来考虑它是这样的:这是一个事件,每当输入更改时触发。这包括 - 但不限于 - 按键修改输入(因此,例如, Ctrl
本身不会触发事件,但 Ctrl-V
粘贴一些文本将会),选择一个自动完成选项,Linux样式的中间点击粘贴,拖放和许多其他的东西。
有关详细信息,请参阅此页面以及有关此答案的评论。 p>
I've never heard of an event in jQuery called input
till I saw this jsfiddle.
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.
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).
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'input'事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!