哪个事件属于“将文本输入到文本字段”使用jQuery [英] Which event belongs to "type text into textfield" using jQuery

查看:118
本文介绍了哪个事件属于“将文本输入到文本字段”使用jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想像一个具有复选框和文本框的格式。如果有人开始键入文本字段bla bla bla whatever,则复选框应该自行勾选。有没有一个对应于打字的事件,或者我必须使用.focus?

Just imagine a formular where there is a checkbox and a textfield. If someone starts typing into the textfield "bla bla bla whatever", the checkbox should tick itself. Is there a event that corresponds to the typing or do I have to use .focus ?

推荐答案

在打字时触发的事件是:

events which are fired on typing are:


  • onkeydown (jQuery: keydown

  • onkeyup (jQuery: keyup

  • onkeypress (jQuery: keypress

  • onkeydown (jQuery: keydown)
  • onkeyup (jQuery: keyup)
  • onkeypress (jQuery: keypress)

您可以为任何修改或影响用户输入的用户创建事件处理程序。
还要注意 .preventDefault() .stopPropagation()函数,这阻止了默认行为对于一个元素或抑制事件冒泡的DOM。

You may create an event handler to any of those to modify or influence users input. Also be aware of .preventDefault() and .stopPropagation() functions, which prevent the default behavior for an element or suppress the event bubbling up the DOM.

引用: keyup keydown keypress preventDefault() stopPropagation()

这篇关于哪个事件属于“将文本输入到文本字段”使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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