HTML onmousedownEvent Attributes

HTML 事件属性HTML Event Attributes

Examples

Run the script when the mouse button is pressed:

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

Try it yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the onmousedown event attribute


Definition and Usage

The onmousedown attribute fires when the mouse button is pressed.

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

  1. onmousedown
  2. onmouseup
  3. onclick

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

  1. onmousedown
  2. onmouseup
  3. oncontextmenu

Note:The onmousedown attribute cannot be used on 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 Values

Value Description
script Specifies the script to be executed when the onmousedown event is triggered.


HTML 事件属性HTML Event Attributes Other Extensions