jQuery“输入"事件

编程入门 行业动态 更新时间:2024-10-24 15:21:09
本文介绍了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“输入"事件

本文发布于:2023-08-01 18:41:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1270716.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   jQuery   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!