The onmousedown
attribute event is triggered
when pressing down a mouse button on the element.
The order of events related to the onmousedown event for mouse button:
None.
<element onmousedown="script or Javascript function name">
All HTML elements, EXCEPT:
<base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, <title>
onmousedown |
Yes | Yes | Yes | Yes | Yes |
<!DOCTYPE html>
<html>
<body>
<!--from w ww . j a va 2s .c o m-->
<p id="p1" onmousedown="mouseDown()" onmouseup="mouseUp()">
Click the text!
</p>
<script>
function mouseDown() {
console.log("down");
}
function mouseUp() {
console.log("up");
}
</script>
</body>
</html>