Document.createDocumentFragment

JavaScript -> Objekty -> Document -> Metóda createDocumentFragment

Syntax

var docFragment = document.createDocumentFragment();

Popis

Príkaz jazyka JavaScript
Creates an empty document fragment.
docFragment is a reference to an empty DocumentFragment object.

A DocumentFragment is a minimal document object that has no parent. It supports the following DOM 2 methods: appendChild, cloneNode, hasAttributes, hasChildNodes, insertBefore, normalize, removeChild, replaceChild.

It also supports the following DOM 2 properties: attributes, childNodes, firstChild, lastChild, localName, namespaceURI, nextSibling, nodeName, nodeType, nodeValue, ownerDocument, parentNode, prefix, previousSibling, textContent.

Various other methods can take a document fragment as an argument (e.g. Node interface methods such as appendChild and insertBefore), in which case the children of the fragment are appended or inserted, not the fragment itself.

Príklad

var frag = document.createDocumentFragment();
frag.appendChild(document.createTextNode('Ipsum Lorem'));
document.body.appendChild(frag);