function addAttributeValues(element, attributeName, values) {
    values = Array.isArray(values) ? values : [values];

    var
      attributeVal = element.getAttribute(attributeName),
      currentVals = attributeVal ? attributeVal.split(' ') : [];

    for (var i = 0; i < values.length; i++) {
      var value = values[i];
      if (currentVals.indexOf(value) === -1) {
        currentVals.push(value);
      }
    }
    element.setAttribute(attributeName, currentVals.join(' '));
  }
/**
   * Add 1 or more values to an attribute.
   *
   * addAttributeValues(element, attributeName, values)
   *
   * @param element DOM-element
   * @param attributeName string
   * @param values mixed; string or array of strings
   */
Add 1 or more values to an attribute.

@param element DOM-element
@param attributeName string
@param values mixed; string or array of strings
Add 1 or more values to an attribute . @param element DOM - element @param attributeName string @param values mixed ; string or array of strings
function addAttributeValues(element, attributeName, values) {
    values = Array.isArray(values) ? values : [values];
    var
      attributeVal = element.getAttribute(attributeName),
      currentVals = attributeVal ? attributeVal.split(' ') : [];
    for (var i = 0; i < values.length; i++) {
      var value = values[i];
      if (currentVals.indexOf(value) === -1) {
        currentVals.push(value);
      }
    }
    element.setAttribute(attributeName, currentVals.join(' '));
  }
function addAttributeValues ( element , attributeName , values ) { values = Array . isArray ( values ) ? values : [ values ] ; var attributeVal = element . getAttribute ( attributeName ) , currentVals = attributeVal ? attributeVal . split ( ' ' ) : [ ] ; for ( var i = 0 ; i < values . length ; i ++ ) { var value = values [ i ] ; if ( currentVals . indexOf ( value ) === - 1 ) { currentVals . push ( value ) ; } } element . setAttribute ( attributeName , currentVals . join ( ' ' ) ) ; }
Add 1 or more values to an attribute.
Add 1 or more values to an attribute .