js坚持不懈之17:onmousedown、onmouseup 以及 onclick 事件
程序员文章站
2023-08-17 23:01:35
2. ......
<!doctype html> <html> <body> <div onmouseover = "mover(this)" onmouseout = "mout(this)" style = "background-color:green;width:120px;height:20px;padding:40px;color:#ffffff;">把鼠标移到上面</div> <script> function mover(obj) { obj.innerhtml = "谢谢" } function mout(obj) { obj.innerhtml = "把鼠标移到上面" } </script> </body> </html>
2.
<!doctype html> <html> <body> <div onmousedown = "mdown(this)" onmouseup = "mup(this)" style = "background:green;color:#ffffff;width:90px;height:20px;padding:40px;font-size:12px;">请点击这里</div> <script> function mdown(obj) { obj.style.backgroundcolor = "#1ec5e5"; obj.innerhtml = "请释放鼠标按钮" } function mup(obj) { obj.style.backgroundcolor = "green"; obj.innerhtml = "请按下鼠标按钮" } </script> </body> </html>
上一篇: 前戏笑言尽管很幽默
下一篇: JavaScript语句