Click the text to change its color.

``` ---"> Click the text to change its color.

``` ---" />
Easy Tutorial
❮ Event Oncanplaythrough Met Nav Javaenabled ❯

onmousedown Event

Event Object

Example

Execute JavaScript code when the user presses the mouse button:

<p onmousedown="myFunction()">Click the text to change its color.</p>

Definition and Usage

The onmousedown event occurs when a mouse button is pressed down.

Tip: The sequence of events associated with the onmousedown event (for the left/middle mouse button):

The sequence of events associated with the onmousedown event (for the right mouse button):

Syntax

In HTML:

In JavaScript:

Parameter Description
SomeJavaScriptCode Required. The JavaScript to be executed when the event occurs.

Browser Support

All major browsers support the onmousedown event.


Supported HTML Tags for onmousedown Event:

The onmousedown attribute is applicable to all HTML elements except: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>.


More Examples

Popup the clicked mouse button

Popup the element clicked by the user

❮ Event Oncanplaythrough Met Nav Javaenabled ❯