jQuery mouseout() Method (original) (raw)

Last Updated : 11 Jul, 2025

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 `

The mouseover Method
<!-- 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>

Move the mouse pointer over this paragraph.

`

Output:

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

HTML `

The mouseover Method
<!-- 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>

Move the mouse pointer over this paragraph.

`

Output: