Document Object Model DOM (basic knowledge)

Source: Internet
Author: User
DOM is very easy to understand, but it is too official and hard to understand. We will translate it in a very simple language, if you are interested, you can refer to the following description before getting started. DOM is very easy to understand, but what you are talking about is too official and hard to understand, we can translate it in a very simple language. Deepen your understanding of DOM to gain a comprehensive understanding of it.

What is DOM?

The full name of DOM is Document Object Model, which allows scripts to control Web pages, windows, and documents.

Without DOM, JavaScript will be another scripting language. with DOM, it will become a powerful tool for creating dynamic pages. DOM is not part of the JavaScript language, but an application interface built in the browser. Of course, we can simply understand it as a programming interface for HTML and XML documents. It provides a structured representation for the document, which can change the content and presentation of the document.

DOM (Document Object Model) is a set of web standards used to describe how scripts interact and access structured documents. Its function is to parse the documents (including html xml xhtml) supported by the browser as an object. DOM is a programming API that allows developers to read, search, modify, add, and delete data from a document. DOM has nothing to do with the platform and language. That is to say, as long as it supports the DOM platform and programming language, you can write documents.

DOM defines a series of objects, methods, and attributes for accessing, operating, and creating content, structures, styles, and actions in a document. Each webpage element (an HTML Tag) corresponds to an object (an object, an object ".). The labels on the Web page are nested layer by layer, and the outermost layer isThe object model of the document is also nested in layers, but it is often understood as the shape of a tree. The root is a window or document object, which is equivalent to the periphery of the outermost tag, that is, the entire document. Under the root of the tree (this tree is usually painted in reverse, just like a genetic family or family tree. Tree Root is the only common ancestor) is a sub-level object. Sub-objects also have their own sub-objects. Except for the root object, all objects have their own parent objects, the relationship between sub-objects of the same object is sibling. If you have never seen a genealogy, you should know the organizational structure of a company.

DOM is actually a document model described in an object-oriented way. DOM defines the objects required to represent and modify documents, the behavior and attributes of these objects, and the relationship between these objects. DOM can be considered as a tree representation of data and structure on the page, but the page may not be implemented in this way. JavaScript can be used to reconstruct the entire HTML document. You can add, remove, change, or rearrange projects on the page.

To change something on the page, JavaScript needs to obtain an entry to access all elements in the HTML document. This entry, along with methods and attributes for adding, moving, changing, or removing HTML elements, is obtained through the Document Object Model (DOM ).

DOM and JavaScript

We use JavaScript to perform all operations on webpages Through DOM. How to access objects in the DOM?

First, the parent object name, followed by the sub-Object Name, separated by dots.

The Code is as follows:


Please wait Doc ument. write ("hi! How are you! ")


DOM operation Checkbox instance

The Code is as follows:






DOM operation checkbox

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.