Skip to content

Instantly share code, notes, and snippets.

@hrkd
Created May 15, 2013 10:12
Show Gist options
  • Select an option

  • Save hrkd/5582948 to your computer and use it in GitHub Desktop.

Select an option

Save hrkd/5582948 to your computer and use it in GitHub Desktop.
ちょっとずつ育てる。
Object.prototype.getId = function(id){
return document.getElementById(id);
};
Object.prototype.getTag = function(tag){
return document.getElementsByTagName(tag);
};
Object.prototype.addChild=function(tag){
this.appendChild(document.createElement(tag));
return this.childNodes;
};
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);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment