Jquery keyup() event method; Through this tutorial, i am going to show you how to use jQuery keyup event with html elements.
jQuery keyup() Event Method
The keyup() event occurs when a keyboard button/key is released. This keyup () method triggers the keyup event, or attach a function to run when a keyup event occurs.
Syntax jQuery keyup() Event Method
$(selector).keyup()
This triggers the keydown event for the selected elements.
$(selector).keyup(function)
Parameters of jQuery keyup() Event Method
Parameter | Description |
---|---|
Function | It is an optional parameter. It is executed itself when the keypress event is triggered. |
Examples 1 – jQuery keyup() Event Method
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script> $(document).ready(function(){ $("input").keydown(function(){ $("input").css("background-color", "green"); }); $("input").keyup(function(){ $("input").css("background-color", "pink"); }); }); </script> </head> <body> Fill the Input Box: <input type="text"> </body> </html>
Demo 1 – jQuery keyup() Event Method
Fill the Input Box:
Example 2 – jQuery keyup alert on released a key of keyboard
<html> <head> <title>Jquery Keyup() Event </title> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> </head> <body> <b> <h4>Press and release a key from the keyboard </h4> </b> </body> <script> $(document).keyup(function(event) { alert('You have released a key'); }); </script> </html>
Demo 2 – jQuery keyup alert on released a key of keyboard
Press and release a key from the keyboard
Recommended jQuery Tutorial
Recommended:-How to Get Element by class, name, id in jQuery
Recommended:-jQuery Events List with Example
Recommended:-jQuery Click() Event Example
Recommended:-jQuery Blur Event Method Example
Recommended:-jQuery Focus () Event Method Example
Recommended:-jQuery Toggle Show Hide div on Click
Recommended:-jQuery Select Event Method
Recommended:-jQuery Get Selected Dropdown Option Value onchange
Recommended:-jQuery Form Submit On Button Click
Recommended:-jQuery Keydown Event Example