Javascript 事件的小实例:
通过点击按钮使div的颜色发生改变
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>事件</title> <style type="text/css"> div{width:150px;height:150px;border:1px solid #f60;}</style> </head> <body> <div id="dv"></div><br> <input type="button" value="点击" onclick="bt()"> <script type="text/javascript"> function bt(){ var div=document.getElementById("dv"); div.style.backgroundColor="red"; } </script> </body> </html>