Created
May 16, 2013 10:21
-
-
Save hrkd/5590782 to your computer and use it in GitHub Desktop.
イベントの登録・解除をjQueryぽく。
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
| Object.prototype.addEvent=function(type,func){ | |
| var tmpFnc = func; | |
| eval("var "+type.split(".")[1]+"=tmpFnc"); | |
| this.addEventListener(type.split(".")[0], eval(type.split(".")[1]), false); | |
| }; | |
| Object.prototype.removeEvent=function(type){ | |
| this.removeEventListener(type.split(".")[0], eval("this."+type.split(".")[1]), false); | |
| }; | |
| //target.addEvent("click.name",function(){}); | |
| //target.removeEvent("click.name"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment