js-- 事件委托笔记

//事件绑定

functionMyAddEvent(obj,sEvent,fn){
    if(obj.attachEvent){
        obj.attachEvent("on"+sEvent,fn);
    }else{
        obj.addEventListener(sEvent,fn,false);
    };
};
//事件解除绑定
functionremoveMyAddEvent(obj,sEvent,fn){
    if(obj.detachEvent){
        obj.detachEvent("on"+sEvent,fn);
    }else{
        obj.removeEventListener(sEvent,fn,false);
    };
};
 

 

 

posted @ 2013-03-18 10:56  GM_Lv  阅读(813)  评论(0编辑  收藏  举报