文档对象模型dom
The DOM
or Document Object Model
is the representation of objects and hierarchy in a document which is generally an HTML or XML document. DOM is the skeleton of a document where changes over DOM generally change the document visually.
DOM
或Document Object Model
是文档(通常是HTML或XML文档)中对象和层次结构的表示。 DOM是文档的骨架,在DOM上进行更改通常会在视觉上更改文档。
什么是DOM(文档对象模型)? (What Is DOM (Document Object Model)?)
DOM provides a structured and hierarchical presentation about the document. DOM is mostly used for Web pages where they contain a lot of different elements related to each other. DOM can be edited by using JavaScript which will reflect the Web page. DOM provides object-oriented presentations for JavaScript where JavaScript objects can be used to manipulate.
DOM提供了有关文档的结构化和分层表示。 DOM主要用于网页,其中包含许多彼此相关的不同元素。 可以使用反映网页JavaScript来编辑DOM。 DOM为JavaScript提供了面向对象的演示,其中可以使用JavaScript对象进行操作。
DOM标准 (DOM Standard)
DOM standard is created by W3C in 1998 with the name of Dom Level 1
which provides the complete model for the entire HTML or XML documents. DOM Level 2
is published in 200 where the getElementByID
function is introduced. DOM Level 3
is published in 2004 and XPath support and event handling are added. DOM Level 4
was published in 2015 by the WHATWG and W3C.
DOM标准由W3C在1998年创建,名称为Dom Level 1
,它为整个HTML或XML文档提供了完整的模型。 DOM Level 2
发布于200年,其中引入了getElementByID
函数。 DOM Level 3
在2004年发布,并添加了XPath支持和事件处理。 DOM Level 4
由WHATWG和W3C于2015年发布。
如何访问DOM? (How To Access DOM?)
DOM can be accessed in different ways and tools like JavaScript, Web Browser DOM Editor, etc. But in order to make a change in a reliable way and automize them, JavaScript is the best way. JavaScript stores the complete DOM in the object name document
.We can use different properties of the document object to access DOM objects.
可以通过不同的方式和工具(例如JavaScript,Web浏览器DOM编辑器等)来访问DOM。但是,为了以可靠的方式进行更改并使它们自动化,JavaScript是最好的方法。 JavaScript将完整的DOM存储在对象名称document
。我们可以使用文档对象的不同属性来访问DOM对象。
document.head
document.body
contains the body part of the HTML web page. childElementCount will provide the count of the child elements. document.body.childeren will return all children as HTMLCollection. document.body.firstChild
will return the first HTML child element.
document.body
包含HTML网页的正文部分。 childElementCount将提供子元素的计数。 document.body.childeren将所有子级作为HTMLCollection返回。 document.body.firstChild
将返回第一个HTML子元素。
DOM数据类型和接口(DOM Data Types and Interfaces)
In order to use and change DOM with JavaScript, some data types and interfaces are provided.
为了通过JavaScript使用和更改DOM,提供了一些数据类型和接口。
Document
is the complete DOM document where all of the HTML elements can be accessed. document
JavaScript object is used to access the Document.
Document
是可以访问所有HTML元素的完整DOM文档。 document
JavaScript对象用于访问Document。
Node
is a node in the DOM hierarchy. Nodes are connected to each other hierarchically where some nodes can be other nodes parent or child. The root node is the Document object.
Node
是DOM层次结构中的节点。 节点彼此分层连接,其中某些节点可以是父级或子级的其他节点。 根节点是Document对象。
翻译自: https://www.poftut.com/what-is-dom-document-object-model/
文档对象模型dom