Javascript Ajax jQuery Html PHP Example Quiz New MORE

jQuery mouseleave() method with example

The mouseleave() method is an inbuilt method in jQuery which works when mouse pointer is leave the selected HTML element.

Syntax:

$(selector).mouseleave(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").mouseenter(function(){
	$("input").css("background-color", "yellow");
  });
  $("input").mouseleave(function(){
	$("input").css("background-color", "green");
  });
});
</script>
</head>
<body>

<input type="text">
<p>Enter and leave the mouse on input box to see the effects.</p>
</body>
</html>
Run it Yourself »