setAttributeNode

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

MDN Reference