function addEvent(type, handler) {
if(this.addEventListener) {
this.addEventListener(type, handler, false);
} else if(element.attachEvent) {
this.attachEvent('on' + type, handler);
} else {
this['on' + type] = handler;
}
}比如有个元素 var btn = document.getElementById('btn');我想这样: btn.addEvent('click', fuction() {});
添加回答
举报
0/150
提交
取消