Skip to content
Related Articles

Related Articles

jQuery | mouseleave() with Examples

View Discussion
Improve Article
Save Article
  • Last Updated : 13 Feb, 2019
View Discussion
Improve Article
Save Article

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



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

Return Value: This method returns the selected element with the changes made by mouseleave() method.

Below example illustrates the mouseleave() method in jQuery:


<!DOCTYPE html>
        <title>The mouseleave Method</title>
        <script src=
        <!-- jQuery code to show the working of this method -->
            $(document).ready(function() {
                $("p").mouseleave(function() {
                    $("p").css("background-color", "lightgreen");
            body {
                width: 300px;
                padding: 40px;
                height: 30px;
                border: 2px solid green;
                font-weight: bold;
                font-size: 20px;
        <!-- move over this paragraph and see the change -->
        <p>Welcome to GeeksforGeeks!</p>

Before moving mouse over paragraph:

After moving mouse over the paragraph.

Related Articles:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!