HTML onmousedown Event Attribute

Example

Execute a JavaScript when the mouse button is pressed on a paragraph:

<p onmousedown="mouseDown()"!Please click on this text!</p>

Try it yourself

Browser Support

IE Firefox Chrome Safari Opera

All major browsers support the onmousedown attribute.

Definition and Usage

The onmousedown attribute is triggered when the mouse button is pressed down on the element.

Tip:Event sequence relative to the onmousedown event (limited to left/middle mouse button):

  1. onmousedown
  2. onmouseup
  3. onclick

Event sequence relative to the onmousedown event (limited to right mouse button):

  1. onmousedown
  2. onmouseup
  3. oncontextmenu

Note:The onmousedown attribute is not applicable to the following elements: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style> or <title>.

Differences between HTML 4.01 and HTML5

None.

Syntax

<element onmousedown="script">

Attribute Value

Value Description
script Script executed when the onmousedown event occurs.