W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>本例演示如何将 "onmousedown" 和 "onmouseup" 事件分配给 p 元素。</p> <p id="demo" onmousedown="mouseDown()" onmouseup="mouseUp()">点击我.</p> <script> function mouseDown() { document.getElementById("demo").innerHTML = "The mouse button is held down."; } function mouseUp() { document.getElementById("demo").innerHTML = "You released the mouse button."; } </script> </body> </html>