CSS Portal
Run
Search
« Back to
HTML onmousedown Event Attribute
<!DOCTYPE html> <html> <head> <title>onmousedown and onmouseup event</title> <style> div { width: 100px; height: 50px; border: 1px solid black; color: black; text-align: center; } </style> </head> <body> <p>Click on an element to demonstrate the script:</p> <div id="code" onmousedown="mouseDown()" onmouseup="mouseUp()">♠ ♣ ♥ ♦<br>♦ ♥ ♣ ♠ </div> <script> function mouseDown() { document.getElementById("code").style.backgroundColor="orange"; } function mouseUp() { document.getElementById("code").style.backgroundColor="purple"; } </script> </body> </html>
If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!
☕ Buy a Coffee