<div id="one" lang="en-US">one</div>
<div id="two">two</div>Element: setAttributeNode() method / notebook
Element: setAttributeNode() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const d1 = document.getElementById("one");
const d2 = document.getElementById("two");
const a = d1.getAttributeNode("lang");
d2.setAttributeNode(a.cloneNode(true));
// Returns: 'en-US'
console.log(d2.attributes[1].value);