标签:.class cto class com classlist function tor lis javascrip
(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‘);
标签:.class cto class com classlist function tor lis javascrip
原文地址:http://www.cnblogs.com/leijuan/p/6123777.html