THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML onmousedown Event Attribute

HTML Event Attributes HTML Event Attributes

Example

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

<p onmousedown="mouseDown()">Click the text!</p>
Try it yourself »

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

Browser Support

Event Attribute
onmousedown Yes Yes Yes Yes Yes

Differences Between HTML 4.01 and HTML5

None.


Syntax

<element onmousedown="script">

Attribute Values

Value Description
script The script to be run on onmousedown

Technical Details

Supported HTML tags: All HTML elements, EXCEPT: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>

Related Pages

HTML DOM reference: onmousedown event


HTML Event Attributes HTML Event Attributes