SO - 30184181

by Arun P Johny

HTML

<div id="x"></div>

JavaScript

var tdiv = document.createElement('div');
tdiv.innerHTML = '<div>testing html</div>&nbsp;asdf';

var el = document.getElementById('x')
while (tdiv.firstChild) {
    el.appendChild(tdiv.firstChild);
}