Skip to content

Instantly share code, notes, and snippets.

@TheRolfFR
Last active January 26, 2022 10:28
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 TheRolfFR/62088d02fae200c9d113846067be3e8e to your computer and use it in GitHub Desktop.
Save TheRolfFR/62088d02fae200c9d113846067be3e8e to your computer and use it in GitHub Desktop.
Creates html from string and appends it to current element
/**
* Creates html from string and appends it to current element
* @author TheRolf
* @param {String} str html string to append
*/
Element.prototype.appendHTML = function(str) {
var div = document.createElement('div')
div.innerHTML = str
while (div.children.length > 0) {
this.appendChild(div.children[0])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment