onmousedown event
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:
- onmousedown
- onmouseup
- onclick
Order (on the right mouse button) scored onmousedown event with event-related:
- onmousedown
- onmouseup
- oncontextmenu
grammar
In HTML:
<element
onmousedown="SomeJavaScriptCode">
In JavaScript:
object .onmousedown=function(){SomeJavaScriptCode};
参数 | 描述 |
---|---|
SomeJavaScriptCode | 必需。规定该事件发生时执行的 JavaScript。 |
Browser Support
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>.
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 objects