当鼠标按钮在 HTML 中某个元素上释放时执行脚本?
鼠标按钮在某个元素上释放时,onmouseup 事件触发。你可以尝试运行以下代码来实现onmouseup 属性 −
示例
<!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>
广告