Javascript Ajax jQuery Html PHP Example Quiz New MORE

jQuery keyup() Method

The keyup event is sent to an element when the user releases a key on the keyboard. It is an inbuilt function of jQuery.

Syntax:

$(selector).keyup(function)

Example:

	<!DOCTYPE html>
	<html>
	<head>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	<script>
	$(document).ready(function(){
	   $("input").keyup(function(){
		 var data=$("input").val();
		 $("#message").html(data);
	  });
	});
	</script>
	</head>
	<body>

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

	<p id="message"></p>

	</body>
	</html>
	The keydown events happens when a key is pressed down. It is an inbuilt function of jQuery.
	Syntax:

	$(selector).keydown(function)
	<!DOCTYPE html>
	<html>
	<head>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	<script>
	$(document).ready(function(){
	   $("input").keydown(function(){
		 var data=$("input").val();
		 $("#message").html(data);
	  });
	});
	</script>
	</head>
	<body>

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

	<p id="message"></p>

	</body>
	</html>

Run it Yourself »