jQuery mouseout() with Examples


The mouseout() method in jQuery is used to trigger the mouseout event. It occurs when the mouse pointer leaves the selected element.

Syntax

The syntax is as follows −

$(selector).mouseout(func)

Example

Let us now see an example to implement the jQuery mouseout() method 

 Live Demo

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function(){
      $("h1").mouseover(function(){
         $("h1").css("color", "green");
      });
      $("h1").mouseout(function(){
         $("h1").css("color", "orange");
      });
   });
</script>
</head>
<body>
<h1>Demo Heading1</h1>
</body>
</html>

Output

This will produce the following output −

Now, when the mouse pointer is over the selected element −

Now, when the mouse pointer leaves the selected element, the text color changes again −

Updated on: 30-Dec-2019

219 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements