revision:
setAttributeNodeNS() method adds a new namespaced attribute node to an element.
setAttributeNodeNS(attributeNode)
Parameters:
attributeNode : an Attr node.
// <div id="one" xmlns:myNS="http://www.mozilla.org/ns/specialspace" // myNS:special-align="utterleft">one</div> // <div id="two">two</div> const myns = "http://www.mozilla.org/ns/specialspace"; const d1 = document.getElementById("one"); const d2 = document.getElementById("two"); const a = d1.getAttributeNodeNS(myns, "special-align"); d2.setAttributeNodeNS(a.cloneNode(true)); alert(d2.attributes[1].value); // returns: `utterleft'