dddddd

(function(window){
    var com = function(box){
        this.box = document.querySelector(box);
	}
	window.zhanglei = function(box){
		return new com(box);
	}
	com.prototype ={
		addClass:function(cls){
		    if('classList' in this.box){
		        this.box.classList.add(cls);
		    }else{
		        var preCls = this.box.className;
		        var newCls = preCls +' '+ cls;
		        this.box.className = newCls;
		    }
		    return this.box;
		}
	}
	
})(window)
zhanglei('.box').addClass('zhang');

  

posted @ 2016-12-01 22:01  <张磊>  阅读(184)  评论(0)    收藏  举报