当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > DOM 介绍
The HTML Document Object Model (HTML DOM) defines a standard way for accessing and manipulating HTML documents.
HTML文档对象模型(HTML DOM)定义了一种访问并操作HTML文档的标准方法
Before you continue you should have a basic understanding of the following:
在你继续前你应该有下面相关方面的基础知识:
If you want to study these subjects first, find the tutorials on our Home page.
如果你想先学习这些知识的话,在我们的首页寻找教程
"The W3C Document Object Model (DOM) is a platform and language neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
“W3C文档对象模型(DOM)是一个能够让程序和脚本动态访问和更新文档内容、结构和样式的语言平台”
The W3C DOM provides a standard set of objects for representing HTML and XML documents, and a standard interface for accessing and manipulating them.
W3C DOM提供了标准的HTML和XML对象集,并有一个标准的接口来访问并操作他们
The DOM is separated into different parts (Core, XML, and HTML) and different levels (DOM Level 1/2/3):
DOM被分为不同的部分(核心,XML和HTML)和不同的版本(DOM 1/2/3)
The HTML DOM views HTML documents as a tree structure of elements embedded within other elements. All elements, their containing text and their attributes, can be accessed through the DOM tree. Their contents can be modified or deleted, and new elements can be created by the DOM. The elements, their text, and their attributes are all known as nodes.
HTML DOM将HTML文档视为嵌套其他元素的树型结构元素。所有的元素,它们包含的文字以及他们的树型都可以被DOM树所访问到。它们的内容可以修改和删除,并且可以通过DOM建立新的元素。元素的文字和它们的属性被识别为点。
The HTML DOM is platform and language independent. It can be used by any programming language like Java, JavaScript, and VBScript.
HTML DOM是独立的语言平台,它可以被任何的程序语言所使用JAVA,JS,VBS)
In this tutorial we will use JavaScript.
在这个教程里我们使用的是JS
This coding example shows how the background color of an HTML document can be changed to yellow when a user clicks on it:
例子中的代码展示了怎样让背景颜色因用户的点击而变为黄色:
<html> |
Try it yourself自己尝试下
The example above is explained in details in the next chapter of this tutorial.
上面的例子我们会在下一篇章里详细解释