The mouseup event fires when the user releases a mouse button over an element — the release half of every click. This tutorial covers binding with .on("mouseup"), triggering with .trigger("mouseup"), pairing with mousedown, detecting buttons with event.which, and comparing mouseup with click.
01
.on()
Bind handler
02
.trigger()
Fire mouseup
03
event.which
Button ID
04
vs click
Release only
05
mousedown
Press half
06
Since 1.7
Modern API
Fundamentals
Introduction
Every click is a press followed by a release. The mouseup event is the release half — it fires when the user lets go of the mouse button while the pointer is over an element. Drag handles, drawing tools, and custom sliders finish on mouseup. Pair it with mousedown to track the full press-and-release gesture.
The official jQuery API distinguishes the mouseupevent (bound with .on("mouseup") since 1.7) from the deprecated .mouseup()method used in older code. To programmatically fire a handler, use .trigger("mouseup") — available since jQuery 1.0. Any HTML element can receive the mouseup event.
Concept
Understanding the mouseup Event
The mouseup event is sent to an element when the mouse pointer is over the element and the mouse button is released. jQuery normalizes this across browsers and gives you a consistent event object with properties like event.which, event.pageX, and event.preventDefault().
Any mouse button triggers mouseup — left, middle, or right. Use event.which to filter: 1 = left, 2 = middle, 3 = right. jQuery normalizes this property across browsers. If the user presses outside an element, drags onto it, and releases, mouseup still fires on that element — but most UIs do not treat that as a click. Prefer click unless you specifically need release-time behavior.
💡
Beginner Tip
Default to click for buttons, links, and toggles. Reach for mouseup when you need action on release — finishing a drag, ending a drawing stroke, or removing an active-state class. Pair mousedown + mouseup when you need the full press-and-release story.
Foundation
📝 Syntax
The modern jQuery API for the mouseup event has two main forms — binding a handler and triggering the event:
.on() and .trigger() return the original jQuery object for chaining.
Handler return values are ignored unless you use return false (equivalent to preventDefault() + stopPropagation()).
Cheat Sheet
⚡ Quick Reference
Goal
Code
Bind mouseup handler
$("#box").on("mouseup", fn)
Left button only
if (event.which !== 1) return;
Pass data to handler
$("#box").on("mouseup", { id: 1 }, fn)
Delegated mouseup on children
$("#panel").on("mouseup", ".handle", fn)
Trigger mouseup programmatically
$("#target").trigger("mouseup")
Pair press and release
.on("mousedown", down).on("mouseup", up)
Remove mouseup handlers
$("#box").off("mouseup")
Compare
📋 mouseup vs click vs mousedown vs deprecated .mouseup()
Four ways to respond to mouse button interaction — choose the event that matches the moment in the gesture you need.
mouseup
release
Fires when button is released — ideal for drag end
mousedown
press
Fires when button is pressed — regardless of where release happens
click
down+up
Full press-and-release inside element — default for buttons and links
.mouseup() method
deprecated
Old binding shorthand — use .on("mouseup") instead
Hands-On
Examples Gallery
Examples 1–3 follow the official jQuery API documentation. Examples 4–5 cover document-level release for drag end and the difference between mouseup and click. Use the Try-it links to run each snippet in the browser.
📚 Binding & Triggering
Official jQuery demos for mouseup handlers and programmatic triggers.
Example 1 — Official Demo: Bind Handler on #target
Alert when the user releases the mouse button on the target element — the canonical .on("mouseup") pattern.
User releases mouse on #target → alert: "Handler for mouseup called."
Fires on release — after the button is let go
How It Works
.on("mouseup", fn) registers the function on the element. jQuery calls it the moment the browser fires mouseup — when the pointer is over the element and the button is released.
Example 2 — Official Demo: #other Triggers mouseup on #target
One element programmatically fires the mouseup handler on another — note the official API uses click on #other to trigger mouseup on #target.
Release on #target directly → alert runs
Click #other → $("#target").trigger("mouseup") → same alert
Programmatic trigger invokes bound handlers
How It Works
.trigger("mouseup") synthetically fires the mouseup event on #target, running the same handler as a physical release. The official demo binds click on the trigger button — any event can call .trigger("mouseup").
Example 3 — Official Demo: Show Text on mousedown and mouseup
Append “Mouse down.” on press and “Mouse up.” on release — the official API demo for pairing both events.
Press and release on a paragraph:
"Press mouse and release here. Mouse down. Mouse up."
Each press/release cycle appends both labels
How It Works
Chaining .on("mouseup") and .on("mouseup") on the same collection registers both handlers on every matched paragraph. Press appends “Mouse down.”; release appends “Mouse up.” — order follows the user’s physical gesture.
📈 Document Release & Gesture Timing
Patterns from the official API notes — document-level release and understanding when mouseup differs from click.
Example 4 — End Drag on Document mouseup
Start styling on mousedown, then listen for mouseup on document so release anywhere on the page ends the drag — the standard drag-end pattern.
Left mousedown on #drag-box → .dragging class added
Release anywhere (even outside the box) → document mouseup removes .dragging
Binding mouseup on document catches release outside the handle
How It Works
Drag UIs start on mousedown but must finish on mouseup — often on document, not the handle alone. If the user drags quickly and releases outside the box, a handle-only mouseup listener would miss the release. $(document).one("mouseup", fn) runs once and cleans itself up.
Example 5 — mouseup vs click: Press Inside, Release Outside
Demonstrate that mouseup fires on release even if the user pressed inside and dragged outside — but click does not fire on the original zone.
Normal click inside #zone → both "mouseup fired on zone" and "click fired on zone"
Press inside, drag outside, release on #zone edge → mouseup may fire; click on zone does not
Press inside, drag outside, release outside → no events on #zone; click canceled
Prefer click for buttons — use mouseup when release timing matters
How It Works
click requires mousedown and mouseup both inside the same element. Dragging away before release cancels the click on that element. mouseup fires on whichever element is under the pointer at release — which may differ from where the press started. Drag libraries finish on document-level mouseup for this reason.
Applications
🚀 Common Use Cases
Drag end — $(document).one("mouseup", endDrag) after mousedown on a handle.
Drawing tools — begin on mousedown, continue on mousemove, finish on mouseup.
Press feedback — add an active class on mousedown, remove on mouseup on document for instant visual response.
Custom sliders — track pointer on mousedown + document mousemove/mouseup.
EventData labels — $(".node").on("mouseup", { id: 42 }, fn) to pass metadata without closures.
🧠 How the mouseup Event Fits the Click Sequence
1
Pointer over element
User moves cursor over the target — no event yet until a button is pressed.
ready
2
Button pressed
User depresses mouse button — mousedown fires immediately. Your handler can run now.
mousedown
3
Button released
User releases button — mouseup fires. May occur inside or outside the element.
mouseup
4
👉
Click (maybe)
If both down and up happened inside the same element, click fires after mouseup. Otherwise, only mousedown (and mouseup) ran.
Important
📝 Notes
Bind with .on("mouseup", handler) since jQuery 1.7 — not the deprecated .mouseup(handler) method.
Trigger with .trigger("mouseup") since jQuery 1.0.
Any mouse button triggers mouseup — filter with event.which (1=left, 2=middle, 3=right).
Press outside + drag onto element + release still counts as mouseup on that element — usually not treated as a click.
Any HTML element can receive mouseup — not limited to <button> or <a>.
Use document-level mouseup to end drags started on mousedown.
Use .off("mouseup") to remove handlers — avoid deprecated .unbind("mouseup").
For standard button actions, prefer click unless you specifically need release-time behavior.
Compatibility
Browser Support
The mouseup event is a standard DOM event supported in every browser jQuery targets. jQuery’s .on("mouseup") (since 1.7) and .trigger("mouseup") (since 1.0) normalize cross-browser behavior — including event.which for button detection.
✓ jQuery 1.7+
jQuery mouseup event
Supported in jQuery 1.x, 2.x, and 3.x across all modern browsers and IE with supported jQuery versions. Native equivalent: element.addEventListener('mouseup', fn) — jQuery adds collection binding, eventData, delegation, and .trigger() in one chainable API.
100%With jQuery loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
mouseupUniversal
Bottom line: Safe in any jQuery project. Prefer .on('mouseup') over deprecated .mouseup() for binding. Use document-level mouseup to end drags.
Wrap Up
Conclusion
The jQuery mouseup event fires when the user releases a mouse button over an element. Bind handlers with .on("mouseup", fn), finish drags with document-level mouseup, and fire handlers programmatically with .trigger("mouseup").
Remember: mouseup is the release step in the click sequence. Use it when you need release-time behavior — drag ends, stroke completion, removing active states. For normal buttons and links, click is usually the right choice. Pair mousedown with mouseup when you need the full press-and-release story.
Bind with .on("mouseup", handler) — the modern, delegation-capable API
Check event.which === 1 when ending drags or primary-button actions
Pair mouseup with $(document).one("mouseup", fn) for document-level release
Use click for standard button and link behavior
Call .off("mouseup") when removing elements or tearing down handlers
❌ Don’t
Use deprecated .mouseup(handler) for new code — use .on("mouseup")
Replace click with mouseup on buttons unless you need release-time behavior
Bind mouseup only on the drag handle — use document so release outside still ends the drag
Forget to unbind document-level mouseup/mousemove listeners after drag ends
Assume mouseup and click always fire together on simple clicks — drag-away cancels click
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about the mouseup event
Release, pair, trigger.
6
Core concepts
.on01
.on("mouseup")
Bind
API
⚡02
.trigger()
Fire
Programmatic
which03
event.which
Button
Filter
↓04
Release only
Timing
Behavior
click05
vs click
Compare
Sequence
.off06
.off("mouseup")
Unbind
Cleanup
❓ Frequently Asked Questions
The mouseup event fires when the user releases a mouse button while the pointer is over an element. In modern jQuery, bind handlers with .on('mouseup', handler) since version 1.7. Any HTML element can receive this event, not just buttons or links.
mouseup fires when the button is released — click fires only after both mousedown and mouseup occur inside the same element. If the user presses inside an element but drags away and releases outside, mouseup fires on the element under the pointer at release time, but click does not fire on the original element. Use click for standard button actions; use mouseup when you need release-time behavior.
Use .on('mouseup', handler) for binding. The old .mouseup(handler) shorthand still works but is deprecated since jQuery 3.3 — it wraps .on('mouseup'). For unbinding, use .off('mouseup') instead of .unbind('mouseup'). .on() also supports event delegation: .on('mouseup', 'li', fn).
Yes. If the user presses outside an element, drags onto it, and releases the button, mouseup still fires on that element — even though mousedown did not happen there. The official jQuery API notes this is usually not treated as a button press in most UIs, so prefer click unless you specifically need mouseup behavior.
Call .trigger('mouseup') on the target element: $('#target').trigger('mouseup'). Available since jQuery 1.0, trigger runs bound mouseup handlers. To run handlers without bubbling or default actions, use .triggerHandler('mouseup') instead.
Drag UIs typically start on mousedown (press) and finish on mouseup (release). Bind mousedown on the handle to begin tracking, then listen for mouseup on document — $(document).one('mouseup', fn) — so release anywhere on the page ends the drag. mouseup on the handle alone misses releases outside the element.
Did you know?
The official jQuery API notes that if a user presses outside an element, drags onto it, and releases the button, mouseup still fires on that element — but most user interfaces do not count that as a button press. Prefer click for standard actions. Drag libraries start on mousedown, track mousemove, and finish on mouseup — often bound on document so release anywhere ends the gesture.