function addClass(element, className) {
  var classNames = className;

  function _addClass(el, cn) {
    if (!el.className) {
      el.className = cn;
    } else if (!hasClass(el, cn)) {
      if (el.classList) {
        el.classList.add(cn);
      } else {
        el.className += ' ' + cn;
      }
    }
  }

  if (!isArray(className)) {
    classNames = className.trim().split(/\s+/);
  }
  classNames.forEach(_addClass.bind(null, element));

  return element;
}
function addClass(element, className) {
  var classNames = className;

  function _addClass(el, cn) {
    if (!el.className) {
      el.className = cn;
    } else if (!hasClass(el, cn)) {
      if (el.classList) {
        el.classList.add(cn);
      } else {
        el.className += ' ' + cn;
      }
    }
  }

  if (!isArray(className)) {
    classNames = className.trim().split(/\s+/);
  }
  classNames.forEach(_addClass.bind(null, element));

  return element;
}
function addClass ( element , className ) { var classNames = className ; function _addClass ( el , cn ) { if ( ! el . className ) { el . className = cn ; } else if ( ! hasClass ( el , cn ) ) { if ( el . classList ) { el . classList . add ( cn ) ; } else { el . className += ' ' + cn ; } } } if ( ! isArray ( className ) ) { classNames = className . trim ( ) . split ( / \s+ / ) ; } classNames . forEach ( _addClass . bind ( null , element ) ) ; return element ; }
Add one or more classnames to an element
@param {Element} element
@param {Array.<string>|String} array of classnames or string with
classnames separated by whitespace
@return {Element}
Add one or more classnames to an element