Created
June 28, 2018 13:13
-
-
Save dragos199993/577b34ed6fae78f4c78d56947a84b955 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(el, str) { | |
var div = document.createElement('div'); | |
div.innerHTML = str; | |
while (div.children.length > 0) { | |
el.appendChild(div.children[0]); | |
} | |
} | |
var test = "hi"; | |
var html = `<h1 id="title">Some ${test}</h1><span style="display:inline-block; width=100px;">Some arbitrary text</span>`; | |
appendHtml(document.body, html); // "body" has two more children - h1 and span. | |
document.body.appendChild(body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment