javascript - Should I use document.createDocumentFragment or document.createElement -


I was reflow and DOM and wondering how to document.createDocumentFragment from document .createElement is different from as it seems that none of them are present in the DOM unless I add them to a DOM element.

I did a test (below) and all of them at the same time (about 95 mms) of the same estimation, this could be due to no style being applied to any element, so anybody Can not Refuge

Anyway, based on the example given below, why should I use the createDocumentFragment instead of createDocumentFragment when inserting the dot and both What is the difference between

  var htmz = "
    "; For written "+ i + ' & lt; / li & gt; (var i = 0; i & lt; 2001; i ++) {htmz + ='

The difference is that when you add it to the DOM, a document section effectively disappears. What happens is that all children in the document fragment are located in the node DOM , Where you insert the document section and the piece of the document is not included. This piece is in existence, but now there is no child.

This allows you to insert several nodes in the DOM at the same time:

  var frag = document.createDocumentFragment (); Var textNode = frag.appendChild (document.createTextNode ("some text")); Var br = frag.appendChild (document.createElement ("br")); Var body = document.body; Body.appendChild (frag); Warning (body.lastchild.tagName); // "BR" warning (body.lastChild.previousSibling.data); // "some text" warning (frag.hasChildNodes ()); // false  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -