Mozilla.com

  1. MDC
  2. Main Page
  3. DOM
  4. document.createDocumentFragment

« Gecko DOM Reference

Summary

Creates an empty document fragment.

Syntax

var docFragment = document.createDocumentFragment();

docFragment is a reference to an empty DocumentFragment object.

Example

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

Notes

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.

Specification

DOM Level 2: createDocumentFragment

Languages

Page last modified 06:33, 11 Jun 2008 by Brettz9

Files (0)