1function create(htmlStr) {
2 var frag = document.createDocumentFragment(),
3 temp = document.createElement('div');
4 temp.innerHTML = htmlStr;
5 while (temp.firstChild) {
6 frag.appendChild(temp.firstChild);
7 }
8 return frag;
9}
10
11var fragment = create('<div>Hello!</div><p>...</p>');
12// You can use native DOM methods to insert the fragment:
13document.body.insertBefore(fragment, document.body.childNodes[0]);
14