Friday, June 12, 2026
HomeLanguagesJavascriptjQuery mouseout() Method

jQuery mouseout() Method

The jQuery mouseout() method is an inbuilt method which is used when mouse pointer moves out from the selected element. 

Syntax:

$(selector).mouseout(function)

Parameters: This method accepts single parameter function which is optional. This parameter is used to specify the function to run when the mouseout event is called. 

Example 1: This example illustrates the use of mouseout() method.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>The mouseover Method</title>
    <script src=
    </script>
  
    <!-- jQuery code to show the working of this method -->
    <script>
        $(document).ready(function () {
            $("p").mouseover(function () {
                $("p").css("background-color", "lightgreen");
            });
            $("p").mouseout(function () {
                $("p").css("background-color", "lightgray");
            });
        });
    </script>
    <style>
        body {
            width: 420px;
            padding: 40px;
            height: 30px;
            border: 2px solid green;
            font-weight: bold;
            font-size: 20px;
        }
    </style>
</head>
  
<body>
    <!-- move over this text to see the change -->
    <p>Move the mouse pointer over this paragraph.</p>
</body>
  
</html>


Output: 

 

Example 2: In this example, a pop-up will come out when the mouse moves out from the paragraph.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>The mouseover Method</title>
    <script src=
    </script>
  
    <!-- jQuery code to show the working of this method -->
    <script>
        $(document).ready(function () {
            $("p").mouseover(function () {
                $("p").css("color", "red");
            });
            $("p").mouseout(function () {
                alert("Mouse moved out from the paragraph");
            });
        });
    </script>
    <style>
        body {
            width: 420px;
            padding: 40px;
            height: 30px;
            border: 2px solid green;
            font-weight: bold;
            font-size: 20px;
        }
    </style>
</head>
  
<body>
    <!-- move over this text to see the change -->
    <p>Move the mouse pointer over this paragraph.</p>
</body>
  
</html>


Output:

 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS