Created
March 5, 2012 11:29
-
-
Save icai/1977941 to your computer and use it in GitHub Desktop.
addEventSimple & removeEventSimple
This file contains 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
function addEventSimple(obj, evt, fn) {//常用函数 | |
if (obj.addEventListener) // W3C | |
obj.addEventListener(evt, fn, false); | |
else if (obj.attachEvent) // Microsoft | |
obj.attachEvent('on' + evt, fn); | |
}; | |
function removeEventSimple(obj, evt, fn) { | |
if (obj.removeEventListener) | |
obj.removeEventListener(evt, fn, false); | |
else if (obj.detachEvent) | |
obj.detachEvent("on" + evt, fn); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment