Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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