Skip to content

Instantly share code, notes, and snippets.

@shinnn
Last active December 12, 2015 09:09
Show Gist options
  • Save shinnn/4749792 to your computer and use it in GitHub Desktop.
Save shinnn/4749792 to your computer and use it in GitHub Desktop.
var addEvent;
if('addEventListener' in window){
addEvent = function(elm, eventType, func){
elm.addEventListener(eventType, func, false);
};
}else if('attachEvent' in window){ // IE
addEvent = function(elm, eventType, func){
elm.attachEvent('on'+eventType, function(){ func.apply(elm); });
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment