绑定事件

$('#test').on('click', function(){})


var addEvent = function(dom, type, handle, capture) {   
  if(dom.addEventListener) {   
    dom.addEventListener(type, handle, capture);   
  } else if(dom.attachEvent) {   
    dom.attachEvent("on" + type, handle);   
  }
};



var t = document.getElementById('test');
addEvent(t, 'click', function(){});

移除事件

$('#test').off('click', fn);


var deleteEvent = function(dom, type, handle) {   
  if(dom.removeEventListener) {    
    dom.removeEventListener(type, handle);   
  } else if(dom.detachEvent) {   
    dom.detachEvent('on' + type, handle);   
  }
};

var t = document.getElementById('test');

deleteEvent(t, 'click', fn);