<!DOCTYPE HTML><html><head> <meta charset="UTF-8" /> <title>50</title></head><body> <input type="button" value="按钮" id="bot1"> <script type="text/javascript"> var b1=document.getElementById("bot1"); var addHandle={ add:function(element,type,handle){ if(element.addEventListener){ element.addEventListener(type,handle,false); } else if(element.attachEvent){ element.attachEvent("on"+type,handle); } else{ element["on"+type]=handle; } },//为什么要加逗号。 remove:function(element,type,handle){ if(element.removeEventListener){ element.removeEventListener(type,handle,false); } else if(element.detachEvent){ element.detachEvent("on"+type,handle); } else{ element["on"+type]=null; } } } function my_a(){ alert("Hello"); } addHandle.add(bot1,"click",my_a); //addHandle.remove(bot1,"click",my_a); </script></body></html>
添加回答
举报
0/150
提交
取消