慕粉3346016
2016-11-12 00:06
<!DOCTYPE html> <html> <head> <title>DOM 0|2</title> <meta charset="utf-8"> </head> <body> <input type="button" value="按钮1" id="btn1"> <script type="text/javascript"> var btn1=document.getElementById("btn1"); function get(){ alert("hello"); } var eventSelect={ addHandler:function(element,type,handler){ if (element.addEventListener) { element.addEventListener(type,handler,false); } else if (element.attachEvent) { element.attachEvent('on'+type,handler); } else{ element['on'+type]=handler; } }, removeHandler:function(element,type,handler){ if (element.removeEventListener) { element.removeEventListener(type,handler,false); } else if (element.attachEvent) { element.detachEvent('on'+type,handler); } else{ element['on'+type]=null; } } } eventSelect.addHandler(btn1,'clcik',get); </script> </body> </html>
line 75: eventSelect.addhandler(btn1,"click",get);,你把'click'写成了"clcik"
DOM事件探秘
99545 学习 · 1197 问题
相似问题