jQuery keyup() Event Method

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

ParameterDescription
FunctionIt 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


Jquery Keyup() Event

Press and release a key from the keyboard


Recommended jQuery Tutorial

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *