<style type="text/css"> #a{width:100px;height:100px;background-color:#F00} </style> </head> <body> <div id="a"></div> </body> <script type="text/javascript">
//找到ID为a的元素 var b = document.getElementById("a");
//给元素绑定点击事件 b.onclick = function(){ alert("aa"); }
</script>