Created
November 20, 2018 22:37
-
-
Save miguel-leon/adfe40d28d6e230fce32fc3521553544 to your computer and use it in GitHub Desktop.
parse html and append to element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function appendHtml(element, content) { | |
const aux = document.createElement(element.tagName); | |
aux.innerHTML = content; | |
for (let i = 0; i < aux.children.length; i++) { | |
element.appendChild(aux.children[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://developer.mozilla.org/en-US/docs/Web/API/Document/importNode
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template