Skip to content

Instantly share code, notes, and snippets.

@bitdivine
Last active August 4, 2016 18:50
Show Gist options
  • Save bitdivine/e7ff85a666b220f8f8b8025832ce7e8d to your computer and use it in GitHub Desktop.
Save bitdivine/e7ff85a666b220f8f8b8025832ce7e8d to your computer and use it in GitHub Desktop.
text2html
function text2html(html,wrappertag){var wrapper= document.createElement(wrappertag||'div');wrapper.innerHTML= html;return wrapper;}
function getscript(url){var script = document.createElement('script');script.type = 'text/javascript';script.src = url;document.head.appendChild(script);}
@bitdivine
Copy link
Author

bitdivine commented Aug 4, 2016

Usage:

document.body.appendChild(text2html('<h1>Hello There!</h1><p>Once upon a time in a galaxy far, far away...</p>'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment