In the mozill api docs for outerHTML is stated, that when seeting outerHTML
:
Replaces the element with the nodes generated by parsing the string content with the parent of element as the context node for the fragment parsing algorithm.
However, when I tried this in the console it didnt work:
var d = document.createElement('div')
d.outerHTML = '<p>Some Text</p>'
console.log(d) //<div>
Can someone explain to me why this isnt working as expected?
// EDIT: Accoring to comments I should append it to a rendering context. The following still not work for me:
var d = document.createElement('div')
document.body.appendChild(d)
d.outerHTML = '<p>Some Text</p>'
console.log(d) //<div>
// EDIT2: Looking at the generated source, the element indeed gets replaced. However, d
is still a div. Well - thats confusing. Why is that so?
Some Text
'; console.log(d); //