removeHandler: function(element, type, handler) {
if(element.removeEventListener) {
element.removeEventListener(type, handler, false);
} else if(element.detachEvent) {
element.detachEvent("on" + type + handler);
} else {
element["on" + type] = null;
}
}
}
var on = document.getElementById("button");
var set = function(){
console.log("1");
}
//调用方法 EventUtil.addHandler(触发元素,触发事件,执行函数);
EventUtil.addHandler(on,"click",set);
此方法来至《javascript高级程序设计》