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() {});
相关分类