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

查看:142
本文介绍了哪个事件属于“将文本键入文本字段”使用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 ?

推荐答案


  • onkeydown (jQuery: c $ c>)

  • onkeyup (jQuery: keyup

  • onkeypress (jQuery: keypress

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

您可以创建一个事件处理程序来修改或影响用户输入。
还要注意 .preventDefault() .stopPropagation()函数,它们防止默认行为

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 按键 keypress preventDefault () stopPropagation()

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

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