HTML DOM 教程
HTML DOM - 事件
一个简单的 onmousedown-onmouseup 实例
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <div onmousedown="mDown(this)" onmouseup="mUp(this)" style="background-color:#D94A38;width:90px;height:20px;padding:40px;">Click Me</div> <script> function mDown(obj) { obj.style.backgroundColor = "#1ec5e5"; obj.innerHTML = "Release Me" } function mUp(obj) { obj.style.backgroundColor = "#D94A38"; obj.innerHTML = "Thank You" } </script> </body> </html>
运行结果:
点击运行 »