JavaScript Advanced Programming: Chapter Tenth-DOM

Source: Internet
Author: User

1. What is DOM?

The DOM (Document Object model) is an API (Application programming Interface) for HTML and XML documents. The DOM depicts a hierarchical tree of nodes that allows developers to add, remove, and modify portions of a page.

2. Node hierarchy

Document nodes are the following nodes for each document. The document element is the outermost element of the document, and all other elements in the document are contained within the document element. In an HTML page, the document element is always an element. In XML, there are no predefined elements, so any element can be a document element.

Each piece of markup can be represented by a node in the tree: The HTML element is represented by an element node, the attribute (attribute) is represented by an attribute node, the document type is represented by a document type node, and the comment is represented by an annotation node. There are 12 node types, all of which inherit from a base type.

2.1 Node Type

The node interface is implemented as a node type in JavaScript, and all node types in JavaScript inherit from the node type. Therefore, all node types share the same basic properties and methods. each node has a NodeType property that indicates the type of the node. The node type is represented by the following 12 numeric constants defined in the node type, and any node type must reside in one of these:

    1. Node.element_node (1);
    2. Node.attribute_node (2);
    3. Node.text_node (3);
    4. Node.cdata_section_node (4);
    5. Node.entity_reference_node (5);
    6. Node.entity_node (6);
    7. Node.processing_instruction_node (7);
    8. Node.comment_node (8);
    9. Node.document_node (9);
    10. Node.document_type_node (10);
    11. Node.document_fragment_node (11);
    12. Node.notation_node (12);

JavaScript Advanced Programming: Chapter Tenth-DOM

Related Article

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.