Skip to content

Instantly share code, notes, and snippets.

@liuqing0224
Last active December 21, 2015 04:09
Show Gist options
  • Select an option

  • Save liuqing0224/6247682 to your computer and use it in GitHub Desktop.

Select an option

Save liuqing0224/6247682 to your computer and use it in GitHub Desktop.
var Base = function(id){
this[0] = document.getElementById(id);
return this;
}
var Class = function(id){
return new Base(id);
}
Base.prototype = Class.prototype = {
html: function(str){
this[0].innerHTML = str;
return this;
},
addClass: function(str){
this[0].className += ' '+str;
return this;
}
}
var obj = Class('test');
obj.html('111').addClass('xxx');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment