Last active
April 20, 2018 06:54
-
-
Save snnwolf/b9f33943dc7e2a1d7a1791d64d66f5fa to your computer and use it in GitHub Desktop.
Подписаться/отписаться на/от события
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var addEvent = function(el, e, callback, capture) { | |
if (!!window.addEventListener) { | |
el.addEventListener(e, callback, !!capture); | |
} else { | |
el.attachEvent("on" + e, callback); | |
} | |
}, | |
removeEvent = function(el, e, callback, capture) { | |
if (!!window.addEventListener) { | |
el.removeEventListener(e, callback, !!capture); | |
} else { | |
el.detachEvent("on" + e, callback); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment