A DocumentFragment node represents a document segment. It is a lightweight 'document' object that can contain other types of nodes and has the ability to access and operate on nodes, but there is no document tag in the document, which is equivalent to a container that is invisible to the page. The constructor is function DocumentFragment () {[native code]}.
The features of DocumentFragment nodes;
- NodeType: 11
- NodeName: # document-fragment
- NodeValue: null
- PrasentNode: null
- Subnode types: Element, Text, Comment, CDATASection, ProcesingInstruction, EntityReference
The DocumentFragment type inherits from Node, which inherits all Node methods and is usually used to perform DOM operations on documents.
If you add a node in the document to the DocumentFragment node, the node is removed from the document tree, so the node is no longer visible in the browser. The new node added to the document tree does not belong to the document tree.
You can use appendChild () and insertBefore () to add the content in the document fragment to the new node.
In fact, the node included in the DocumentFragment type node added to the document tree will never be part of the document tree!
The DocumentFragment type node is equivalent to a 'warehouse '. The nodes it contains are not displayed on the page,
Create a DocumentFragment node; document. createDocumentFragment (),