onmouseup Event

Definition and usage

The onmouseup event occurs when the user releases the mouse button over an element.

Tip:Event order related to onmouseup event (for left-click/middle-click):

  1. onmousedown
  2. onmouseup
  3. onclick

Event order related to onmouseup event (for right-click):

  1. onmousedown
  2. onmouseup
  3. oncontextmenu

Example

Execute JavaScript when the mouse button is released over a paragraph:

<p onmouseup="mouseUp()">Click the text!</p>

Try it yourself

Syntax

In HTML:

<element onmouseup="myScript">

Try it yourself

In JavaScript:

object.onmouseup = function(){myScript};

Try it yourself

In JavaScript, use the addEventListener() method:

object.addEventListener("mouseup", myScript);

Try it yourself

Note:Internet Explorer 8 and earlier versions do not support addEventListener() method.

Technical details

Bubbling: Support
Cancellable: Support
Event types: MouseEvent
Supported HTML tags: All HTML elements except: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style> and <title>
DOM Version: Level 2 Events

Browser Support

Events Chrome IE Firefox Safari Opera
onmouseup Support Support Support Support Support