Latest web development tutorials

jQuery keyup () method

jQuery Event Methods jQuery Event Methods

Examples

When the keyboard key is released, set <input> field background color:

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

try it"

Definition and Usage

The sequence of events associated with the keyup event:

  1. keyDown - key pressed process
  2. the KeyPress - key is pressed
  3. keyup - key is released

keyup event occurs when the keyboard key is released.

keyup () method triggers the keyup event, or when a predetermined function to run the event keyup event.

Tip: Use event.which property to return which key was pressed.


grammar

Trigger the selected element keyup event:

$(selector).keyup() 尝试一下

Add the function to the keyup event:

$(selector).keyup(function) 尝试一下

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


Examples

More examples

Determines which key was pressed
How event.which property to determine which key was pressed.


jQuery Event Methods jQuery Event Methods