Node.js examples for CSS:Class
Element toggle class
Element.prototype.toggleClass = function(tag) { var ret = false var classes = this.className.split(" ") var index = classes.indexOf(tag) if (index >= 0) classes.splice(index,1) else {//from w ww .j a va 2s . c o m classes.push(tag) ret = true } this.className = classes.join(" ") return ret }