1function appendHtml(el, str) {
2 var div = document.createElement('div');
3 div.innerHTML = str;
4 while (div.children.length > 0) {
5 el.appendChild(div.children[0]);
6 }
7}
8var html = '<h1 id="title">Some Title</h1><span style="display:inline-block; width=100px;">Some arbitrary text</span>';
9appendHtml(document.body, html); // "body" has two more children - h1 and span.
10