function fragment(html) { var elt = document.createElement("div"); // Пустой элемент var frag = document.createDocumentFragment(); // Пустой фрагмент elt.innerHTML = html; // Содержимое элемента while (elt.firstChild) // Переместить все узлы frag.appendChild(elt.firstChild); // из elt в frag return frag; // И вернуть frag }