jQuery keyup () method
Examples
When the keyboard key is released, set <input> field background color:
$("input").keyup(function(){
$("input").css("background-color","pink");
});
$("input").css("background-color","pink");
});
try it"
Definition and Usage
The sequence of events associated with the keyup event:
- keyDown - key pressed process
- the KeyPress - key is pressed
- 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 事件触发时运行的函数。 |
More examples
Determines which key was pressed
How event.which property to determine which key was pressed.