Here you can find the source of addClass(className)
Element.prototype.addClass = function(className) { const currentClasses = this.className this.className = `${currentClasses} ${className}`.trim() return this//from w w w .j a v a 2s . c o m }
Element.prototype.addClass=function(className){ var classNames=this.className.split(' '); for(var i=0;i<classNames.length;i++){ if(classNames[i]===className){ return true; this.className+=' '+className; return true; ...
Element.prototype.addClass = function(className){ var existing = this.className.length, spacer = ""; if(existing > 0) spacer = " "; if (!this.hasClass(className)) this.className = (this.className + spacer + className); return this;
Element.prototype.addClass = function(cls) { if (!this.hasClass(cls)) { this.className += " " + cls; } };
Element.prototype.pushClass = function(className){ this.className += ' ' +className