This attribute fires when a mouse button is pressed down on the element. The order of events occur related to the onmousedown event(for the left/mouse button)
- onmousedown
- onmouseup
- onclick
Syntax:
<element onmousedown="script">
Attribute Value: It is supported by all HTML elements. The script event run when onmousedown attribute call.
Example:
<!DOCTYPE html> < html > < head > < title >onmousedown attribute</ title > < style > body { text-align:center; } h1 { color:green; } </ style > </ head > < body > < h1 >GeeksforGeeks</ h1 > < h2 >onmouseDown A ttribute</ h2 > < p id = "sudo" onmousedown = "mouseDown()" onmouseup = "Geeks()" > GeeksForGeeks: A computer science portal for Geeks. It is a < br > best website for learning computer science.</ p > < script > function Geeks() { document.getElementById("sudo").style.color = "green"; } function mouseDown() { document.getElementById("sudo").style.color = "red"; } </ script > </ body > </ html > |
Output:
Supported Browsers: The browser supported by onmousedown attribute are listed below:
- Apple Safari
- Google Chrome
- Firefox
- Opera
- Internet Explorer
leave a comment
0 Comments