The onmouseup attribute is an inline event handler for the mouseup event. It runs when a pointing-device button is released while the pointer is inside the element — the counterpoint to onmousedown.
A full click needs press and release on the same element. MDN also notes that pointerup only fires for the last button release, while mouseup fires for each button release on a physical mouse.
Baseline · Widely available.
Not deprecated and not experimental. Stable across modern browsers since about July 2015.
Accessibility.
Do not make important actions mouse-only. Prefer click (or keyboard-friendly controls) for primary actions so Enter/Space still work.
Syntax
HTML Syntax
syntax.html
<element onmouseup="script">
script is JavaScript that runs on release. Pass event to read event.button, event.clientX, and event.clientY. Script alternative: element.addEventListener("mouseup", handler).
mousedown shows “Pressed” as soon as the press starts.
mouseup shows “Released” when the button comes up over the control.
mouseleave resets if the pointer leaves while held (release may fire elsewhere).
For submit-style actions, prefer onclick so drag-away cancels naturally.
Example 3 — mouseup vs click
Log both events so you can feel the difference when you drag off before release.
HTML
<button type="button" id="btn">Press and release</button>
<ul id="log"></ul>
<script>
var btn = document.getElementById("btn");
var log = document.getElementById("log");
function add(line) {
var li = document.createElement("li");
li.textContent = line;
log.appendChild(li);
}
btn.addEventListener("mouseup", function () {
add("mouseup — button up on this element");
});
btn.addEventListener("click", function () {
add("click — press + release on same element");
});
</script>
Press and release on the button — both mouseup and click log.
Press on the button, release elsewhere — neither may fire on this button (release lands elsewhere).
Press elsewhere, release on the button — you can get mouseup without click.
Prefer addEventListener in apps so multiple handlers can coexist.
Edge Cases & Pitfalls
Release can land on a different element than the press — that is the main source of bugs.
target
Release target can differ from press
Press on A, drag to B, release — mouseup fires on B. click may not fire on either if the path does not qualify.
a11y
Keyboard users skip mouseup
Enter/Space on a real <button> activates via click, not a mouse sequence. Do not require mouseup for primary actions.
pointer
mouseup ≠ pointerup for multi-button
MDN: physical mice fire mouseup for each button release. pointerup fires only for the last button while others may still be held.
context
Right-click still fires mouseup
Secondary-button release triggers mouseup and may involve the context menu (oncontextmenu).
touch
Touch may synthesize mouse events
Phones often emulate mouse after a tap. For multi-device UIs, consider Pointer Events or dedicated touch handling.
Compatibility
Browser Support
onmouseup is an HTML event handler for the mouseup event in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
onmouseup
Widely available since about July 2015. Supported across modern desktop and mobile browsers (with the usual mouse-vs-touch caveats).
98%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetModern
Full support
Internet ExplorerLegacy support
Supported
onmouseupWidely supported
Bottom line: Safe to use for release detection. Prefer click for primary actions; use addEventListener in larger apps.
Remember
Key Takeaways
Role: run script the moment a pointer button is released over the element.
vs click:mouseup is release; click needs press + release on the same element.
API: use event.button and coordinates from the MouseEvent.
A11y: never make critical features mouse-only.
One line: use onmouseup for the release moment — use onclick for completed activation.
Frequently Asked Questions
It is an inline event handler that runs JavaScript when the mouseup event fires — a pointing-device button is released while the pointer is inside the element.
onmousedown runs when the button is pressed. onmouseup runs when it is released. Press and release can happen on different elements if the pointer moves.
mouseup fires on release over that element. click fires after a press and release that stay on the same element. Prefer click for most button actions.
MDN: with a physical mouse, mouseup fires whenever any button is released. pointerup fires only for the last button release while other buttons may still be held.
On a MouseEvent, button is 0 for the primary (usually left) button, 1 for the auxiliary (usually middle/wheel) button, and 2 for the secondary (usually right) button.
No. The mouseup event is Baseline widely available. Inline handlers are fine for learning; apps often use addEventListener("mouseup", handler).