首页 > 其他 > 详细

dddddd

时间:2016-12-02 02:04:52      阅读:196      评论:0      收藏:0      [点我收藏+]
(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‘);

  

dddddd

原文:http://www.cnblogs.com/leijuan/p/6123777.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!