The setAttributeNode() method of the Element interface adds a new Attr node to the specified element.
setAttributeNode()
MDN Reference