1function createElement( str ) {
2 var frag = document.createDocumentFragment();
3
4 var elem = document.createElement('div');
5 elem.innerHTML = str;
6
7 while (elem.childNodes[0]) {
8 frag.appendChild(elem.childNodes[0]);
9 }
10 return frag;
11}
1document.getElementById("Test").innerHTML = "<p style='color:red;'>Test</p>";
1function createElement( str ) {
2 var frag = document.createDocumentFragment();
3
4 var elem = document.createElement('div');
5 elem.innerHTML = str;
6
7 while (elem.childNodes[0]) {
8 frag.appendChild(elem.childNodes[0]);
9 }
10 return frag;
11}
12