🔥 $100K Hit! Where Will Bitcoin Go Next? Find Out Live!

Code has been added to clipboard!

Attach Event Handlers to .mouseup() Event With jQuery mouseup Method

Reading time 1 min
Published Jan 9, 2018
Updated Sep 27, 2019

jQuery mouseup: Main Tips

  • The jQuery .mouseup() binds an event handler to mouseup event, or triggers the event.
  • The mouseup event happens when the mouse button is released while the cursor is still over the element.

Usage of .mouseup() Method

The jQuery .mouseup() sets an event handler, running a function when the mouseup event occurs. The method can invoke the event as well.

Try clicking on the text in the example. If you release the button while still on the text, a message will appear beneath it:

Example
$("div").mouseup(function() {
   $(this).after("<p>Hey there!</p>");
});

Use this syntax to trigger the mouseup event:

$("selector").mouseup();

Add the function parameter to attach the event handler:

$("selector").mouseup(function);

Tip: to make jQuery get mouse position, use event.pageX and event.pageY.