HTML event onmousedown

From Htmlpedia
Jump to: navigation, search

Event Attribute onMouseDown

onMouseDown is an event attribute, it takes JavaScript-code as a value. The code will be executed when:

  • The user pressed their mouse or pointing device button down (does not require release) whilst hovering above the element.

Example

In this example, the user will receive a messagebox saying "You pressed your mouse button whilst hovering over this text", after pressing the mouse/pointing device button down anywhere over the text "Hover over me and click"

<a onmousedown="alert('You pressed your mouse button whilst hovering over this text')">Hover over me and click</a>

Controversy

As this event requires the user to move the mouse/pointing device and use it's buttons, users with impaired motor skills or no mouse may find this difficult or impossible.

Related

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup