Nodejs HTML Element Class Toggle toggleClass(tag)

Here you can find the source of toggleClass(tag)

Method Source Code

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  .  jav a 2 s  .  c o  m
    classes.push(tag)
    ret = true
  }
  this.className = classes.join(" ")
  return ret
}