HTML DOM Chinese Reference Manual

Read(19397) update time(2022-04-13)

In the "HTML DOM Chinese Reference Manual", HTML DOM defines the standard method of accessing and manipulating HTML documents. DOM represents HTML documents in a tree structure.


HTML DOM is the abbreviation of HTML Document Object Model. HTML DOM is a document object model specifically suitable for HTML/XHTML. People familiar with software development can understand HTML DOM as the API of a web page. It treats each element in the web page as an object, so that the elements in the web page can also be obtained or edited by computer language. For example, Javascript can use HTML DOM to dynamically modify web pages.

DOM is the abbreviation of Document Object Model. According to the W3C DOM specification, DOM is a browser-, platform-, and language-independent interface that allows you to access other standard components in the page. Simply understood, DOM resolves the conflict between Netscape's JavaScript and Microsoft's JavaScript, giving web designers and developers a standard way to access data, scripts, and presentation layer objects in their sites.

DOM is a collection of nodes or information fragments organized in a hierarchical structure. This hierarchy allows developers to navigate the tree looking for specific information. Analyzing this structure typically requires loading the entire document and constructing the hierarchy before any work can be done. Because it is based on information hierarchy, the DOM is considered tree-based or object-based.

HTML DOM defines standard methods for accessing and manipulating HTML documents.

HTML DOM presents HTML documents as a tree structure (node ​​tree) with elements, attributes, and text.

Tips: Before you continue to learn HTML DOM, you need to understand HTML, CSS, JavaScripHave a basic understanding of the content.

Node information

In the HTML DOM, everything is a node. DOM is HTML viewed as a tree of nodes.

Each node has attributes that contain some information about the node. These attributes are:

nodeName (node ​​name) nodeValue (node ​​value) nodeType (node ​​type)

According to the W3C's HTML DOM standard, all content in an HTML document is a node:

  • The entire document is a document node

  • Each HTML element is an element node

  • Within the HTML element The text is a text node

  • Each HTML attribute is an attribute node

  • The comment is a comment node

Tips: Our HTML DOM tutorial will help you learn HTML DOM step by step. If you have any questions, please go to the PHP Chinese website HTML DOM Community to ask your questions , there will be enthusiastic netizens to answer your questions.

HTML DOM Methods

Methods are actions we can perform on nodes (HTML elements).

  • Programming interface

The HTML DOM can be accessed through JavaScript (and other programming languages).

All HTML elements are defined as objects, and the programming interface is object methods and object properties.

Methods are actions you can perform (such as adding or modifying elements).

Attributes are values ​​that you can get or set (such as the name or content of a node).

  • HTML DOM Object - Methods and Properties

Some commonly used HTML DOM methods:

  • getElementById(id) - Get the node (element) with the specified id

  • appendChild(node) - Insert a new child node (element)

  • removeChild(node) - Remove child node (element)

Some commonly used HTML DOM attributes:

  • innerHTML - Node (element) Text value of

  • parentNode - the parent node of the node (element)

  • childNodes - the child node of the node (element)

  • attributes - attribute node of a node (element)

What this HTML DOM tutorial manual covers

This HTML DOM tutorial manual covers all HTML Basic knowledge of DOM, including DOM nodes, DOM methods, DOM attributes, DOM access, DOM elements, DOM events, etc.

Tips: Each chapter of this tutorial contains many HTML DOM examples. You can directly click the "Run Example" button to view the results online. These examples will help you better understand and learn the HTML DOM.

Other HTML DOM related learning reference resources

In addition to the knowledge expansion on the right side of this page, the following resources are also selected for everyone

Latest chapter


HTML DOM 对象 2016-10-20
HTML DOM 实例 2016-10-18
HTML DOM总结 2016-10-18
HTML DOM 导航 2016-10-18
HTML DOM - 事件 2016-10-18
HTML DOM - 元素 2016-10-18
HTML DOM - 修改 HTML 内容 2016-10-18
HTML DOM - 修改 2016-10-18