var eventUntil={
addHandler:function(element,type,handler){
if(element.addEventListener){
element.addEventListener(type,handler,false);
}else if(element.attchEvent){
element.attchEvent('on'+type,handler);
}else{
element['on'+type] = handler;
}
},
eventHandler:function(element,type,handler){
if(element.removeEventListener){
element.removeEventListener(type,handler,false);
}else if(element.detachEvent){
element.detachEvement('on'+type,handler);
}else{
element['on'+type] = handler;
}
}
}
var btn5 = document.getElementById("btn5");
eventUntil.addHandler(btn5,'click',four);
跟你一样,也是运行不出来,求解决
eventHandler:function(element,type,handler){
if(element.removeEventListener){
element.removeEventListener(type,handler,false);
}else if(element.detachEvent){
element.detachEvement('on'+type,handler);
}else{
element['on'+type] = handler;
}
这句这边应该也要写成 element['on'+type] = null;
你是想删除的吧?
这句错了:element.detachEvement('on'+type,handler);
修正为:element.detachEvent("on"+type,handler);
还有这句我不知道你有没有做four这个函数处理:eventUntil.addHandler(btn5,'click',four);
修正为:eventUtil.addHandler(btn5,"click",function(){alert("测试")});