Skip to content

Instantly share code, notes, and snippets.

@bloodyowl
Created June 20, 2012 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bloodyowl/2962515 to your computer and use it in GitHub Desktop.
Save bloodyowl/2962515 to your computer and use it in GitHub Desktop.
addEvent
// a = element
// b = event (string)
// c = function to call
addEvent = function(a, b, c) {
if ("addEventListener" in window) { // !(IE)
a.addEventListener(b, function(d){
d.preventDefault();
c.call(a);
}, false)
} else { // IE
a.attachEvent("on" + b, function() {
c.call(a);
return false
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment