Revision: 7393
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 21, 2008 17:55 by iTony
Initial Code
var elems = [ document.createElement("hr"), text( document.createElement("b"), "Links:" ), document.createTextNode(" "), text( document.createElement("a"), "Link A" ), document.createTextNode(" | "), text( document.createElement("a"), "Link B" ), document.createTextNode(" | "), text( document.createElement("a"), "Link C" ) ]; function text(node, txt){ node.appendChild( document.createTextNode(txt) ); return node; } // append fragment instead of all the nodes. var div = document.getElementsByTagName("div"); var fragment = document.createDocumentFragment(); for ( var e = 0; e < elems.length; e++ ) { fragment.appendChild( elems[e] ); } for ( var i = 0; i < div.length; i++ ) { div[i].appendChild( fragment.cloneNode(true) ); }
Initial URL
http://ejohn.org/blog/dom-documentfragments/
Initial Description
Initial Title
Appending fragments to the DOM instead of every node.
Initial Tags
DOM
Initial Language
JavaScript