jQuery mouseup Event

Beginner
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Mouse events

What You’ll Learn

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

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 mouseup event (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.

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.

📝 Syntax

The modern jQuery API for the mouseup event has two main forms — binding a handler and triggering the event:

1. Bind a handler — .on("mouseup" [, eventData ], handler) (since 1.7)

jQuery
.on( "mouseup" [, eventData ], handler )
  • eventData — optional object passed to the handler as event.data.
  • handler — function called each time mouseup fires: function( event ) { ... }.

2. Event delegation — .on("mouseup", selector, handler)

jQuery
$( "#canvas" ).on( "mouseup", ".handle", function( event ) {
  // runs when any .handle inside #canvas is pressed
} );

3. Trigger the event — .trigger("mouseup") (since 1.0)

jQuery
.trigger( "mouseup" )
  • Runs bound mouseup handlers on the matched element(s).
  • Use .triggerHandler("mouseup") to run handlers without bubbling or default actions.

4. Unbind — .off("mouseup" [, selector] [, handler])

jQuery
$( "#target" ).off( "mouseup" );              // remove all mouseup handlers
$( "#canvas" ).off( "mouseup", ".handle", fn ); // remove delegated handler

Official jQuery API examples

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

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

Return value

  • .on() and .trigger() return the original jQuery object for chaining.
  • Handler return values are ignored unless you use return false (equivalent to preventDefault() + stopPropagation()).

⚡ Quick Reference

GoalCode
Bind mouseup handler$("#box").on("mouseup", fn)
Left button onlyif (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")

📋 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

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.

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

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.

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

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

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.

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

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.

jQuery
$( "#drag-box" ).on( "mousedown", function( event ) {
  if ( event.which !== 1 ) {
    return;
  }
  var $box = $( this );
  $box.addClass( "dragging" );
  $( document ).one( "mouseup", function() {
    $box.removeClass( "dragging" );
  } );
} );
Try It Yourself

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.

jQuery
var $log = $( "#log" );

$( "#zone" )
  .on( "mouseup", function() {
    $log.append( "<p>mouseup fired on zone</p>" );
  } )
  .on( "click", function() {
    $log.append( "<p>click fired on zone</p>" );
  } );
Try It Yourself

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.

🚀 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.
  • Proxy triggers$("#btn").on("click", function(){ $("#target").trigger("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.

📝 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.

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 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
mouseup Universal

Bottom line: Safe in any jQuery project. Prefer .on('mouseup') over deprecated .mouseup() for binding. Use document-level mouseup to end drags.

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.

💡 Best Practices

✅ Do

  • 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

Key Takeaways

Knowledge Unlocked

Six things to remember about the mouseup event

Release, pair, trigger.

6
Core concepts
02

.trigger()

Fire

Programmatic
which 03

event.which

Button

Filter
04

Release only

Timing

Behavior
click 05

vs click

Compare

Sequence
.off 06

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

Next: .mouseup() Method

Learn the deprecated shorthand for binding and triggering mouseup — and how to migrate to .on("mouseup").

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

6 people found this page helpful