jQuery | mouseup() with Examples

The mouseup() method is an inbuilt method in jQuery which works when mouse left button is released over a selected element.

Syntax:

$(selector).mouseup(parameter)

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



Return Value: This method returns the selected element with the change when function is called.

Below examples illustrate the mouseup() method in jQuery:

Example 1: This example contains parameter.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>The mouseup Method</title>
        <script src=
        </script>
          
        <!-- jQuery code to show the working of this method -->
        <script>
            $(document).ready(function() {
                $("button").mouseup(function() {
                    $("div").after(
                     "<p style='color:green;'>Mouse button released.</p>");
                });
            });
        </script>
        <style>
            body {
                width: 200px;
                padding: 20px;
                min-height: 100px;
                border: 2px solid green;
            }
        </style>
    </head>
    <body>
        <!-- click on this button and release -->
        <button>Click Here!</button>
          
    </body>
</html>

chevron_right


Output:
Before click on the button:

After click on the button:

Program 2: This example does not contain parameter.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>The mouseup Method</title>
        <script src=
        </script>
          
        <!-- jQuery code to show the working of this method -->
        <script>
            $(document).ready(function() {
                $("div").mouseover(function() {
                    $("p").mouseup().slideToggle();
                });
            });
        </script>
        <style>
            body {
                width: 340px;
                padding: 20px;
                height: 100px;
                border: 2px solid green;
                font-weight: bold;
                font-size: 20px;
            }
        </style>
    </head>
    <body>
       
        <p>Welcome to GeeksforGeeks!</p>
          
        <!-- move over this text to see the change -->
        <div>Mouse over this text to see the change.</div>
       
    </body>
</html>

chevron_right


Output:
Before moving mouse over the div element:

After moving the mouse over the div element:

Related Articles:



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.