jQuery keydown() 方法

jQuery 教程 · 2019-03-09 20:29:25

实例

当键盘键被按下时,设置 <input> 字段的背景颜色:

$("input").keydown(function(){ $("input").css("background-color","yellow"); });

定义和用法

与 keydown 事件相关的事件顺序:

  1. keydown - 键按下的过程
  2. keypress - 键被按下
  3. keyup - 键被松开

当键盘键被按下时发生 keydown 事件。

keydown() 方法触发 keydown 事件,或规定当发生 keydown 事件时运行的函数。

提示:请使用 event.which 属性来返回哪个键盘键被按下。

语法

触发被选元素的 keydown 事件:

  
    $(selector).keydown()

  

添加函数到 keydown 事件:

  
    $(selector).keydown(function)

  

参数 描述
function 可选。规定 keydown 事件触发时运行的函数。

点击查看所有 jQuery 教程 文章: https://www.codercto.com/courses/l/35.html

查看所有标签

Haskell Programming from first principles

Haskell Programming from first principles

Christopher Allen、Julie Moronuki / 2015 / USD 59.00

I am writing this book because I had a hard time learning Haskell. It doesn't have to be that way. I've spent the last couple years actively teaching Haskell online and in person. Along the way, I ......一起来看看 《Haskell Programming from first principles》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

随机密码生成器
随机密码生成器

多种字符组合密码