HTML onmousedown Event Attribute HTML Reference



Example

Execute a JavaScript when pressing a mouse button over a paragraph:

<p onmousedown="mouseDown()">Click the text!</p>

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

1. Definition and Usage

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

Tip: The order of events related to the onmousedown event (for the left/middle mouse button):

  1. onmousedown
  2. onmouseup
  3. onclick

The order of events related to the onmousedown event (for the right mouse button):

  1. onmousedown
  2. onmouseup
  3. oncontextmenu

Note: The onmousedown attribute CANNOT be used with: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, or <title>.


2. Differences Between HTML 4.01 and HTML5

None.


3. Syntax

<element onmousedown="script">

4. Attribute Values

ValueDescription
scriptThe script to be run on onmousedown

Relative articles