Skip to content

Instantly share code, notes, and snippets.

@Hupotronic
Created September 17, 2012 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hupotronic/3740467 to your computer and use it in GitHub Desktop.
Save Hupotronic/3740467 to your computer and use it in GitHub Desktop.
Create a document fragment from text
var innerFrag = function(content) {
var frag, div;
frag = document.createDocumentFragment();
div = document.createElement('div');
div.innerHTML = content;
for( var i = 0, ii = div.childNodes.length; i < ii; i++ ) {
frag.appendChild(div.childNodes[i].cloneNode(true));
}
return frag;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment