jQuery mouseup Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Mouse Events

Definition

mouseup is sent when the mouse button is released while the pointer is over an element. Bind it with .on("mouseup", handler) (jQuery 1.7+).

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$("#target").on("mouseup", function () { ... })
$("#target").trigger("mouseup")

// Fires on release (any button)
// Prefer on/trigger — not the deprecated .mouseup()
// Left button: event.which === 1
CallWhat it does
mouseupLearn the jQuery mouseup event: bind with .on(\

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Select the element(s): $("#box"), $("p"), etc.
Step 2Bind: .on("mouseup", function (event) { ... }).
Step 3Optional: gate on event.which === 1 for the left button.

Return Value

Return ValueDescription
jQuery objectMost setters and traversing helpers return the jQuery collection so you can chain more methods.

jQuery Examples

Example 1 — Bind a mouseup Handler

Official style: .on("mouseup", …) on a target element.

jQuery
$("#target").on("mouseup", function () {
  console.log("Handler for mouseup called.");
});
Try It Yourself

How It Works

  1. Select #target.
  2. Bind with .on("mouseup", handler).
  3. User releases a mouse button over the element.

Example 2 — Trigger mouseup from Code

Fire the same handlers with a single click on another control.

jQuery
$("#target").on("mouseup", function () {
  console.log("Handler for mouseup called.");
});

$("#other").on("click", function () {
  $("#target").trigger("mouseup");
});
Try It Yourself

How It Works

  1. Bind the real handler on #target.
  2. Another control listens for its own click.
  3. trigger("mouseup") runs #target’s handlers.

Example 3 — Left Button Only (event.which)

End drag-like actions only on the primary button release.

jQuery
$("#box").on("mouseup", function (event) {
  if (event.which !== 1) {
    return; // ignore middle / right
  }
  console.log("Primary button released");
});
Try It Yourself

How It Works

  1. which is normalized by jQuery: 1 / 2 / 3.
  2. Return early if it is not the left button.
  3. Right release does not run your primary logic.

Frequently Asked Questions

mouseup fires when the mouse button is released while the pointer is over an element. Bind with .on("mouseup", handler) (jQuery 1.7+). Any HTML element can receive it.
Prefer .on("mouseup", handler). The .mouseup(handler) shorthand is deprecated since jQuery 3.3. To fire the event, use .trigger("mouseup") instead of .mouseup().
mouseup fires on release under the pointer. click needs both mousedown and mouseup inside the same element. Prefer click for normal buttons; use mouseup when you need release-time behavior.
Yes. Press outside, drag onto an element, then release — mouseup still fires on that element. The jQuery API notes most UIs do not treat this as a button press, so prefer click unless mouseup is intentional.
Call $(selector).trigger("mouseup"). That runs bound handlers. Use .triggerHandler("mouseup") to run handlers without bubbling or default actions.
Start on mousedown, finish on mouseup. For drag-end, listen on document — e.g. $(document).one("mouseup", fn) — so release anywhere ends the drag, not only over the handle.

Next: .mouseup() Method — Deprecated Shorthand

See the deprecated helper and how it maps to on / trigger.

.mouseup() Method — Deprecated Shorthand tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful