Skip to content

Instantly share code, notes, and snippets.

@lonfee88
Created April 15, 2016 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lonfee88/8f0bc12c2af1c927d05192ce9cb49a95 to your computer and use it in GitHub Desktop.
Save lonfee88/8f0bc12c2af1c927d05192ce9cb49a95 to your computer and use it in GitHub Desktop.
dom2html
function nodeToString ( node ) {
var tmpNode = document.createElement( "div" );
tmpNode.appendChild( node.cloneNode( true ) );
var str = tmpNode.innerHTML;
tmpNode = node = null; // prevent memory leaks in IE
return str;
}
//http://stackoverflow.com/questions/4239587/create-string-from-htmldivelement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment