示例您可以尝试运行以下代码来实现onmousedown属性 -
<!doctype html><html> <body> <h3 id = "myid" onmousedown = "mousedown()" onmouseup = "mouseup()"> this is demo heading. </h3> <p>click above and then release.</p> <script> function mousedown() { document.getelementbyid("myid").style.color = "yellow"; } function mouseup() { document.getelementbyid("myid").style.color = "blue"; } </script> </body></html>
以上就是当在html元素上按下鼠标按钮时执行脚本?的详细内容。