HTML Dom (i): Understanding DOM

Source: Internet
Author: User

What is DOM?
With JavaScript, you can refactor an entire HTML document. You can join, remove, change, or rearrange items on a page. To change something on a page, JavaScript needs to access all the elements in the HTML document. This portal, along with the methods and properties for adding, moving, changing, or removing HTML elements, is obtained through the Document Object Model (DOM). In 1998, the first level of the DOM specification was published by the consortium. This specification agrees to access and manipulate each individual element in an HTML page. All browsers run this standard, so the DOM compatibility issue is almost impossible to trace. The DOM can be used by JavaScript to read, change HTML, XHTML, and XML documents.


The DOM is divided into different sections (core, XML, and HTML) and levels (DOM level 1/2/3):
Core DOM
Defines a standard set of objects for whatever structured document
XML DOM
Defines a standard set of objects for an XML document
HTML DOM
Defines a set of standard objects for HTML documents.

Node
Each ingredient in the dom,html document is a node.
This is what the DOM provides:

    • The entire document is a document node
    • Each HTML tag is an element node
    • Text that is included in the HTML element is a text node
    • Each HTML attribute is an attribute node
    • Gaze belongs to the gaze node
Node Hierarchy
Nodes have hierarchical relationships with each other. All the nodes in the HTML document make up a document tree (or node tree). Each element, attribute, text, and so on in an HTML document represents a node in the tree. The tree starts at the document node and continues to extend its branches until it is at the lowest level of all text nodes in the tree.

The following image represents a document tree (node tree):


Document tree (number of nodes)
Take a look at this HTML document:

All of the above nodes have relationships with each other. Each node except the document node has a parent node. For example, the parent node of,

HTML Dom (i): Understanding DOM

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.