- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML onmousedown Event Attribute
The HTML onmousedown event attribute is triggered when a mouse button is pressed down on an HTML element in an HTML document.
Syntax
Following is the syntax −
<tagname onmousedown=”script”></tagname>
Let us see an example of HTML onmousedown event Attribute−
Example
<!DOCTYPE html> <html> <head> <style> body { color: #000; height: 100vh; background-color: #FBAB7E; background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%); text-align: center; } .circle { background: #db133a; height: 150px; width: 150px; border-radius: 50%; margin: 10px auto; } p { margin: 30px auto; } </style> </head> <body> <h1>HTML onmousedown Event Attribute Demo</h1> <div class="circle" onmousedown="mouseDownFn()" onmouseup="mouseUpFn()"></div> <p>Try to click the above red circle</p> <script> function mouseDownFn() { document.querySelector('.circle').style.transform = 'scale(0.5)'; } function mouseUpFn() { document.querySelector('.circle').style.transform = 'scale(1.2)'; } </script> </body> </html>
Output
Click on “red” circle to observe how onmousedown event attribute works.
- Related Articles
- HTML onblur Event Attribute
- HTML onclick Event Attribute
- HTML onchange Event Attribute
- HTML oncopy Event Attribute
- HTML oncut Event Attribute
- HTML oncontextmenu Event Attribute
- HTML ondrag Event Attribute
- HTML onfocus Event Attribute
- HTML oninput Event Attribute
- HTML oninvalid Event Attribute
- HTML onpaste Event Attribute
- HTML onresize Event Attribute
- HTML onreset Event Attribute
- HTML onsubmit Event Attribute
- HTML onscroll Event Attribute

Advertisements