jQuery keyup() 方法

jQuery 教程 · 2019-03-09 21:27:11

实例

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

$("input").keyup(function(){ $("input").css("background-color","pink"); });

定义和用法

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

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

当键盘键被松开时发生 keyup 事件。

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

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

语法

触发被选元素的 keyup 事件:

  
    $(selector).keyup()

  

添加函数到 keyup 事件:

  
    $(selector).keyup(function)

  

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

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

查看所有标签

Head First Rails

Head First Rails

David Griffiths / O'Reilly Media / 2008-12-30 / USD 49.99

Figure its about time that you hop on the Ruby on Rails bandwagon? You've heard that it'll increase your productivity exponentially, and allow you to created full fledged web applications with minimal......一起来看看 《Head First Rails》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具