Nodejs Utililty Methods HTML Element Class Toggle

List of utility methods to do HTML Element Class Toggle

Description

The list of methods to do HTML Element Class Toggle are organized into topic(s).

Method

toggleClass(tag)
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 {
    classes.push(tag)
    ret = true
  this.className = classes.join(" ")
  return ret