Latest web development tutorials

onmousedown event

Event Object Reference Event objects

Examples

Javascript code execution when the user presses the mouse button:

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

try it"
(Bottom of this page there are more examples)

Definition and Usage

onmousedown event occurs when the mouse button is pressed.

Tip: onmousedown event-related order (left mouse / middle button) scored the incident:

  1. onmousedown
  2. onmouseup
  3. onclick

Order (on the right mouse button) scored onmousedown event with event-related:

  1. onmousedown
  2. onmouseup
  3. oncontextmenu

grammar

In HTML:

<element onmousedown="SomeJavaScriptCode">

In JavaScript:

object .onmousedown=function(){SomeJavaScriptCode};

参数 描述
SomeJavaScriptCode 必需。规定该事件发生时执行的 JavaScript。


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support onmousedown event


Onmousedown event supported HTML tags:

onmousedown HTMl property applies to all elements except: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>.


Examples

More examples

Click the mouse button pops up
Pop user clicks the mouse button

The user clicks on the pop-up elements
Pop user clicked element name.


Event Object Reference Event objects