jQuery | mouseout() with Examples

The mouseout() method is an inbuilt method in jQuery 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.

Return Value: This method returns the selected element with the change.



Below example illustrates the mouseout() method in jQuery:

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:
Mouse over the paragraph:

Mouse move out from the paragraph:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.