lib/index.esm.js
function addClassName(el, cls) {
  if (!cls || !(cls = cls.trim())) {
    return;
  }
  var clsArr = cls.split(/\s+/);
  if (el.classList) {
    clsArr.forEach(function (c) {
      return el.classList.add(c);
    });
  } else {
    var curCls = ' ' + (el.className || '') + ' ';
    clsArr.forEach(function (c) {
      curCls.indexOf(' ' + c + ' ') === -1 && (curCls += ' ' + c);
    });
    el.className = curCls.trim();
  }
}
function addClassName(el, cls) {
  if (!cls || !(cls = cls.trim())) {
    return;
  }
  var clsArr = cls.split(/\s+/);
  if (el.classList) {
    clsArr.forEach(function (c) {
      return el.classList.add(c);
    });
  } else {
    var curCls = ' ' + (el.className || '') + ' ';
    clsArr.forEach(function (c) {
      curCls.indexOf(' ' + c + ' ') === -1 && (curCls += ' ' + c);
    });
    el.className = curCls.trim();
  }
}
function addClassName ( el , cls ) { if ( ! cls || ! ( cls = cls . trim ( ) ) ) { return ; } var clsArr = cls . split ( / \s+ / ) ; if ( el . classList ) { clsArr . forEach ( function ( c ) { return el . classList . add ( c ) ; } ) ; } else { var curCls = ' ' + ( el . className || '' ) + ' ' ; clsArr . forEach ( function ( c ) { curCls . indexOf ( ' ' + c + ' ' ) === - 1 && ( curCls += ' ' + c ) ; } ) ; el . className = curCls . trim ( ) ; } }
为HTML元素添加className
@param {HTMLElement} el 目标元素
@param {String} cls 要添加的className（多个以空格分割）
为HTML元素添加className