1.点击改变HTML内容
<html> <head> <meta charset="UTF-8"> <script> function showMsg() { document.getElementById("demo").innerHTML="点击后的文本"; } </script> </head> <body> <h1 id="demo" onclick="showMsg()">请点击该文本</h1> </body> </html>
2.鼠标移动或离开事件
<html> <head> <script> function over(obj) { obj.innerHTML="鼠标移至文本"; } function out(obj){ obj.innerHTML="鼠标离开文本"; } </script> </head> <body> <p id="demo" onmouseover="over(this)" onmouseout="out(this)"> 测试鼠标事件 </p> </body> </html>
原文:http://www.cnblogs.com/expiator/p/6728861.html