HTML onmousedown Attribute

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

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):
  • onmousedown
  • onmouseup
  • onclick
  • The order of events related to the onmousedown event (for the right mouse button):

  • onmousedown
  • onmouseup
  • oncontextmenu
  • Applies to

    The onmousedown attribute is part of the Event Attributes, and can be used on any HTML elements.

    Elements Event
    All HTML elements onmousedown

    Example

    P Example

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

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

    Browser Support

    Event Attribute
    onmousedown Yes Yes Yes Yes Yes