全兼容原生绑定事件函数
function addEvent (ele,type,callback){
if(window.addEventListener){
ele.addEventListener(type, function (event) {
callback(event)
},false);
}else if (window.attachEvent) {
ele.attachEvent('on'+type, function (event) {
callback(event)
});
}else {
ele['on'+type]= function (event) {
callback(event)
}
}
};
-
« 上一篇:
php创建数组的方法
-
angular 问题记录1
:下一篇 »