jQuery mouseup Event

Beginner
6 min read
Updated: Oct 2026
5 examples
Live preview

What Is the mouseup Event?

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+).

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

// Fires on release (any button)
// Prefer on/trigger — not the deprecated .mouseup()
// Left button: event.which === 1
NeedUse
Bind handler.on("mouseup", handler)
Fire event.trigger("mouseup")
Which button?event.which (1 / 2 / 3)
Press + releaseclick

How to Use mouseup

Select an element, bind with .on, optionally check event.which.

  1. Select the element(s): $("#box"), $("p"), etc.
  2. Bind: .on("mouseup", function (event) { ... }).
  3. Optional: gate on event.which === 1 for the left button.
  4. To fire in code: .trigger("mouseup"). Unbind with .off("mouseup").
PieceRequired?Role
"mouseup"YesEvent type string for .on / .trigger
handlerYes (bind)Runs on each button release
eventDataOptionalExtra data passed into the handler
Return value—jQuery set (chainable)

Pseudocode

Pseudocode
function onMouseup(element, handler):
    when pointer is over element
     and any mouse button is released:
        handler(event)   // event.which = 1|2|3

trigger(element, "mouseup"):
    run all mouseup handlers on element

Cheat Sheet

Keep these facts handy while wiring release handlers.

TopicDetail
Bind.on("mouseup", handler) (1.7+)
Trigger.trigger("mouseup") (1.0+)
WhenButton released over the element
event.which1 left · 2 middle · 3 right
vs clickRelease only — press may have started elsewhere
Unbind.off("mouseup")
Deprecated.mouseup() shorthand (3.3+)

Live Preview

Run presets that use .on("mouseup") and .trigger("mouseup").

Uses .on("mouseup") and .trigger("mouseup") — same ideas as the examples below.

Result
Handler for mouseup called.

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

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.
  4. Handler runs at release time.

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.
  4. Same message as releasing over #target.

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.
  4. For menus, prefer contextmenu.

Example 4 — Pair with mousedown

Official demo idea: log both press and release on the same element.

jQuery
$("p")
  .on("mousedown", function () {
    $(this).append(" Mouse down.");
  })
  .on("mouseup", function () {
    $(this).append(" Mouse up.");
  });
Try It Yourself

How It Works

  1. mousedown appends text on press.
  2. mouseup appends text on release.
  3. Order is always down then up for a normal press.
  4. Chain both with .on on the same set.

Example 5 — Drag-End on document

Release can happen outside the handle — listen once on document.

jQuery
$("#handle").on("mousedown", function () {
  console.log("Drag start");

  $(document).one("mouseup", function () {
    console.log("Drag end (anywhere)");
  });
});
Try It Yourself

How It Works

  1. mousedown on the handle starts the drag.
  2. .one("mouseup") on document waits for any release.
  3. Release outside the handle still ends the drag.
  4. .one auto-removes the listener after it fires.

Edge Cases & Pitfalls

Watch these when relying on mouseup handlers.

deprecated

Avoid .mouseup() shorthand

Deprecated in 3.3. Use .on("mouseup") / .trigger("mouseup") / .off("mouseup").

vs click

Drag-onto release is still mouseup

Press elsewhere then release on an element still fires mouseup there. Prefer click for finished actions.

drag

End drags on document

Handle-only mouseup misses releases outside the element. Use $(document).one("mouseup", fn).

which

Gate logic on which === 1

Ignoring middle/right releases avoids fighting with scroll-click and context menus.

dynamic

New DOM nodes need delegation

Prefer .on("mouseup", "child", fn) on a stable parent for lists and boards.

Browser Support

The native mouseup event works in all browsers. Bind with .on("mouseup") since jQuery 1.7; .trigger("mouseup") since 1.0. Prefer these over the deprecated .mouseup() shorthand (3.3+).

✓ jQuery 1.7+ (.on)

mouseup event

Supported everywhere jQuery event APIs run in the browser. Use on/trigger for modern code.

100% Browser support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
on("mouseup") Excellent

Bottom line: Bind with .on("mouseup", fn). Check event.which for the primary button. Prefer click when you need a full press-and-release.

Performance Notes

ApproachCostBest for
Direct .on("mouseup")1 handler / elementFew static controls
Delegated .on1 handler / parentLists / canvases / dynamic UI
$(document).one("mouseup")Temporary listenerDrag-end / gesture finish

Keep release handlers light. Use .one for one-shot drag-end listeners so they do not linger after the gesture.

Key Takeaways

  • Bind: .on("mouseup", handler) — not deprecated .mouseup().
  • Timing: fires on release — press may have started elsewhere.
  • Buttons: use event.which (1 left / 2 middle / 3 right).
  • Prefer click for finished actions; mouseup for release / drag-end.

One line: use .on("mouseup", fn) for release handling — listen on document when the gesture can end anywhere.

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() shorthand

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

.mouseup() tutorial →

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