How to get OutterHTML in Javascript?
Examples 1
var d = document.getElementById("d");
console.log(d.outerHTML);
// The string '<div id="d"><p>Content</p><p>Further Elaborated</p></div>'
// is written to the console window
Example 2
var container = document.getElementById("container");
var d = document.getElementById("d");
console.log(container.firstElementChild.nodeName); // logs "DIV"
d.outerHTML = "<p>This paragraph replaced the original div.</p>";
console.log(container.firstElementChild.nodeName); // logs "P"
// The #d div is no longer part of the document tree,
// the new paragraph replaced it.