Full-stack JavaScript (10) Learning DocumentFragment nodes

Source: Internet
Author: User

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 (),

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.