HTML » HTML Core Attributes » onmousedown

Version: 4.0

Syntax:
onmousedown="action"

The onmousedown core attribute is an event handler that is associated with clicking down the mouse button while the mouse is inside a selected HTML tag (element). In other words, the mouse down event occurred while the HTML element was in focus. Every time you click down the mouse, while inside the element, the script code of the onmousedown is executed. This script can also call functions or subroutines which contain code that you want to run when this event occurs.

The four other similar core attributes are: onmousemove, onmouseout, onmouseover, and onmouseup.

Examples

Code:
<input type="button" onmousedown="JavaScript: alert( 'onmousedown event' )"value="Click Down With Mouse!">
Output:
Explanation:

In this example, place the mouse inside on the button element, click down, and hold it. Every time you click down, one line of JavaScript code is executed which causes an alert box to be displayed with a message. Finally, release the mouse and click okay in the alert.

Language(s): HTML

See Also: