为什么没效果?<div id="box">测试</div><script>var box=document.getElementById('box');function showBox(){ alert("OK");}eventUtil.addHandler(box,'click',showBox);</script>
1 回答
已采纳
西兰花伟大炮
TA贡献376条经验 获得超318个赞
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> #box{ width: 100px; height:100px; background-color: red; } </style> </head> <body> <div id="box"></div> <script> var box = document.getElementById("box"); function showBox() { alert("ok"); } box.addEventListener("click",showBox); </script> </body> </html>
这个有效果了,ie添加事件监听是attachEvent
添加回答
举报
0/150
提交
取消