jQuery mouseup: Main Tips
- The jQuery
.mouseup()
binds an event handler tomouseup
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.