jQuery keyup()

The jQuery keyup() method is used to attach a function to run when a keyup event occurs i.e, when a keyboard button is released after pressing.

Syntax:

To trigger the keyup event for selected elements.

$(selector).keyup()

To add a function to the keyup event.

$(selector).keyup(function)

Function:

  • It is an optional parameter.
  • The function parameter specifies the function to run when the event occurs.

 

Example

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){  
	$("input").keydown(function(){  
    	$("input").css("background-color", "turquoise");  
	});  
	$("input").keyup(function(){  
    	$("input").css("background-color", "red");  
	});  
});  
</script>  
</head>  
<body>  
Write something: <input type="text">  
</body>  
</html>

Try it

JS Bin on jsbin.com

Please Share