Javascript Code Remove Any/All Attributes from Element and Its Children

Javascript Code Function that Allows you to Remove All Attributes from and Element or Array of Elements and Optionally All the Elements Children. Exception List Allows you to Keep Certain Desired Attributes such as href, id or class for Example

Home Short:

function removeAttributes(elem, bRemoveChildAttributes, ...exceptionAttributes)

* --------------------------------------------------------------------
   REMOVE ALL ATTRIBUTES FROM ANY ELEMENT
   
    [elem] - the element to remove the attributes from. This can
             can be passed as either a single element such as
             from id or an array ie class or elementsByTagName
             
    [bRemoveChildAttributes] - if [elem] has child nodes, this
                               set to true removes attributes
                               from these child nodes also.
                               
    [...exceptionAttributes] - unlimited list of attributes to
                               not remove.
                               
   EXAMPLE: 
     removeAttributes(
                      document.querySelectorAll('div'), // all divs
                      true, // remove attributes of children of divs
                      'id', 'class', 'href' // keep id, class, href
                     )
  -----------------------------------------------------------------  */

S
H
A
R
E