keyup()

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:

snippet
$(selector).keyup()

It triggers the keyup event for selected elements.

snippet
$(selector).keyup(function)

It adds a function to the keyup event.

Parameters of jQuery keyup() event

Parameter Description
Function It is an optional parameter. It is executed itself when the keypress event is triggered.

Example of jQuery keyup() event

Let's take an example to demonstrate jQuery keyup() event.

snippet
<!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:

Note
Note: If you write something in the above text box then the background color will be changed on keydown and keyup.
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +