The jQuery keyup() event occurs when a keyboard button is released after pressing. This method is executed or attach a function to run when a keyup() event occurs.
Syntax:
$(selector).keyup()
It triggers the keyup event for selected elements.
$(selector).keyup(function)
It adds a function to the keyup event.
Parameter | Description |
---|---|
Function | It is an optional parameter. It is executed itself when the keypress event is triggered. |
Let's take an example to demonstrate jQuery keyup() event.
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script> $(document).ready(function(){ $("input").keydown(function(){ $("input").css("background-color", "red"); }); $("input").keyup(function(){ $("input").css("background-color", "yellow"); }); }); </script> </head> <body> Write something: <input type="text"> </body> </html>
Output: