keyup() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:keyup

Description

The keyup() method triggers the keyup event, or sets function as keyup event handler.

Syntax

$(selector).keyup(function);
Parameter Require Description
function Optional. function to run when the keyup event is triggered.

The following code shows how to set the background color of an <input> field when a keyboard key is released:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("input").keydown(function(){
        $("input").css("background-color", "yellow");
    });// w  w  w  .ja v  a2  s  . co m
    $("input").keyup(function(){
        $("input").css("background-color", "pink");
    });
});
</script>
</head>
<body>

Enter your name: <input type="text">

<p>Enter your name in the input field.</p>

</body>
</html>

Related Tutorials