jQuery mouseup() Method

Last Updated:

jQuery mouseup() Method

The jQuery mouseup() method is used for the following 2 purpose

  1. To run a callback when a specified element is released after pressing.
  2. To trigger the mouseup event of a specified element.

Run a Callback

In the following example, we will run a callback function when a paragraph is released after pressing.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery mouseup() Method</h1> <p>Press and release Me.</p> <script> $(document).ready(function(){ $("p").mouseup(function(){ alert("Paragraph is pressed and released."); }); }); </script> </body> </html>

Syntax

$(selector).mouseup(callback);

Parameter Values

ValueTypeExplanation
callback Optional Specifies a function to be called once user mouse is press and released on the element.

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
mouseup()YesYesYesYesYesYesYesYesYesYesYesYesYes

Trigger a mouseup Event

In the following example, we will trigger a mouseup event when a button is clicked.

Example

HTML Editor
!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery mouseup() Method</h1> <p>Press and release Me.</p> <button>Trigger mouseup Event</button> <script> $(document).ready(function(){ $("p").mouseup(function(){ alert("Paragraph is pressed and released."); }); $("button").click(function(){ $("p").mouseup(); }); }); </script> </body> </html>

Share this Page

Meet the Author