![](https://cdn-r.oss-cn-hangzhou.aliyuncs.com/pro/image/M/question-point-connection.png)
文章链接
js语言和框架-JavaScript语言-事件冒泡和捕捉
面5笔5绑定事件的兼容性写法。
function addEvent(elem,event,fn) {
if(elem.addEventListener){
elem.addEventListener(event,fn,false);
}else if (elem.attachEvent){
elem.attachEvent('on'+event,fn);
}else{
elem[ 'on'+event]=fn;
}
}