Base.prototype.addClass = function (className) { for (var i = 0; i < this.elements.length; i ++) { if (!this.elements[i].className.match(new RegExp('(\s|^)' + className + '(\s|$)'))){ this.elements[i].className += ' ' + className; } } return this; } //移除CLASS Base.prototype.removeClass = function (className) { for (var i = 0; i < this.elements.length; i ++) { if (this.elements[i].className.match(new RegExp('(\s|^)' + className + '(\s|$)'))){ this.elements[i].className = this.elements[i].className. replace(new RegExp('(\s|^)' + className + '(\s|$)'), ' '); } } return this; }