jQuery“输入"事件 [英] jQuery 'input' event

查看:28
本文介绍了jQuery“输入"事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在看到这个 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“输入"事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆