Hello,
I want to clone a node(p element and it’s attributes), delete it, then remake it and use the cloned node for the attributes. I have:
window.onload = retain;
function retain() {
window.bar = document.getElementById("outer").getElementsByTagName('p')[0];
window.cbar = bar.cloneNode(true);
}
function home() {
var foo = document.getElementById("outer")
h3 = document.createElement('h3');
h3.appendChild(document.createTextNode("John Doe"));
foo.appendChild(h3);
p = document.createElement('p');
p.appendChild(document.createTextNode(cbar));
foo.appendChild(p);
}
But where the P element should show “this is text formated correctly” it shows “[object HTMLParagraphElement]”.
Can anyone help?