You can always wrap a clone of an element in an "off screen", an empty container. The innerHTML container is the "outerHTML" of the clone and the original. Pass true as the second parameter to get the children of the elements.
document.getHTML=function(who,deep){
if(!who || !who.tagName) return '';
var txt, el= document.createElement("div");
el.appendChild(who.cloneNode(deep));
txt= el.innerHTML;
el= null;
return txt;
}
source
share