Home >Web Front-end >JS Tutorial >The use and definition of jQuery keyup() event
Overview
Trigger the keyup event for each matching element
This function will call and execute all functions bound to the keyup event, including the browser's default behavior . You can prevent triggering the browser's default behavior by returning false in a bound function. The keyup event is triggered when the key is released.
Parameters
fnFunctionV1.0
The handler function bound in the keyup event of each matching element.
[data],fnString,FunctionV1.4.3
data:keyup([Data], fn) Data can be passed in for function fn to process.
fn: The handler function bound in the keyup event of each matching element.
Example
Description:
Change the color of the text field when a key is pressed:
jQuery Code:
$("input").keyup(function(){ $("input").css("background-color","#D6D6FF"); });
keyup ()Event
The keyup() event occurs when the key is released. Acts on the currently focused element.
Specific application aspects
SearchQuery aspects
When entering the search content in the search input box, press the enter key to perform the search.
<script type="text/javascript"> $(document).ready(function(){ $("#pos_keyword").keyup(function(e){ //pos_keyword就是搜索框,当搜索框按下时响应事件keyup,e就是当前元素element var keycode = e.which; //keycode就是按键的编码,e当前元素element,e.which是当前的编码 if(keycode==13){ //如果keycode等于13就响应方法进行搜索 search_pos(); } }); }) </script>
The above is the detailed content of The use and definition of jQuery keyup() event. For more information, please follow other related articles on the PHP Chinese website!