DOM 介绍

The HTML Document Object Model (HTML DOM) defines a standard way for accessing and manipulating HTML documents.
HTML文档对象模型(HTML DOM)定义了一种访问并操作HTML文档的标准方法


What You Should Already Know
你应该已经知道哪些

Before you continue you should have a basic understanding of the following:
在你继续前你应该有下面相关方面的基础知识:

  • HTML / XHTML
  • JavaScript

 


What is the DOM?
什么是DOM?

"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)

  • Core DOM - defines a standard set of objects for any structured document
    定义了任意结构文档的标准对象集合
  • XML DOM - defines a standard set of objects for XML documents
    定义了针对XML文档的标准对象集合
  • HTML DOM - defines a standard set of objects for HTML documents
    定义了针对HTML文档的标准对象集合

What is the HTML DOM?
什么是HTML DOM?

  • The HTML DOM is the Document Object Model for HTML
    HTML DOM是针对HTML的文档对象模型
  • The HTML DOM is platform and language independent
    HTML DOM是独立的语言和平台
  • The HTML DOM defines a standard set of objects for HTML, and a standard way to access and manipulate HTML documents
    定义了针对HTML的标准对象集合以及访问和操作HTML文档的方法
  • The HTML DOM is a W3C standard
    HTML DOM是一个W3C的标准

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建立新的元素。元素的文字和它们的属性被识别为点。


We Will Use JavaScript
我们将使用JS

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


An HTML DOM Example
一个HTML DOM的例子

This coding example shows how the background color of an HTML document can be changed to yellow when a user clicks on it:
例子中的代码展示了怎样让背景颜色因用户的点击而变为黄色:

<html>

<head>
<script type="text/javascript">
function ChangeColor()
{
document.body.bgColor="yellow"
}
</script>

</head>

<body οnclick="ChangeColor()">
Click on this document!
</body>

</html>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值