document.all

简介:
(1)含义:document.all的意思是文档的所有元素,也就是说它包含了当前网页的所有元素。它是以数组的形式保存元素的属性的,所以我们可以用document.all["元素名"].属性名="属性值"来动态改变元素的属性。
(2)访问文档中的特定元素
document.all["docid"]
document.all["docname"]
document.all.item("docid")
document.all.item("docname")
document.all[0]
document.all.tags("div")返回所有DIV数组,用document.all.tags("div")[0]访问元素
(3)在web标准下可以通过使用getElementById(), getElementsByName(), and getElementsByTagName()访问DOCUMENT中的任一个标签
document.getElementsByName()返回的是一个数组,用document.getElementsByName()[]返回数组中单个值
getElementsByTagName()同样返回的也是一个数组
例子:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="
http://www.w3.org/1999/xhtml " >
<head runat="server">
    <title>document中All</title>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
    <h1>Example Heading</h1>
    <hr />
    <p>This is a <em>paragraph</em>. It is only a <em>paragraph.</em></p>
    <p>Yet another <em>paragraph.</em></p>
    <p>This final <em>paragraph</em> has <em id="special">special emphasis.</em></p>
    <hr />
    <script type="text/javascript">
        var i,origLength;
        origLength = document.all.length;
        document.write('document.all.length='+origLength+"<br />");
        for (i = 0; i < origLength; i++)
        {
            document.write("document.all["+i+"]="+document.all[i].tagName+"<br />");
        }
    </script>
</body>
</html>
结果: 

 

 

 



本文转自 韬光星夜 51CTO博客,原文链接:http://blog.51cto.com/xfqxj/477078,如需转载请自行联系原作者

相关文章
|
运维 安全 Cloud Native
谈谈云原生安全
根据自己的理解 简单谈谈云原生安全
5560 0
谈谈云原生安全
|
Linux Windows
Nomachine 最简安装与使用指南
这是一篇2022年Nomachine软件的极简安装与使用指南,包括Windows和Linux系统下的安装步骤,以及如何在Windows系统上通过Nomachine远程控制Linux系统的方法。
Nomachine 最简安装与使用指南
|
JavaScript
Vue 2 中的 Props
从基础到实战,我们一环都不要少!
434 0
|
弹性计算 运维 Serverless
Serverless应用引擎
Serverless应用引擎
|
存储 监控
西门子S7-1500 PLC之间、PLC与HMI如何建立通信
西门子S7-1500关于通信的功能非常完善,可以说通信无处不在,这其中包括PLC之间的通信,PLC与人机界面的通信。在博途软件中,支持拖拽方式,通过变量的拖拽自动建立通信,这极大的提高了工程效率。今天我们从三个方面介绍S7-1500的通信。看完本文您会发现通信也是如此简单与高效。
西门子S7-1500 PLC之间、PLC与HMI如何建立通信
安装WPS
安装WPS
565 0
|
Serverless 程序员 双11
|
存储 C语言
【C 语言】二级指针作为输入 ( 自定义二级指针内存 | 二级指针排序 | 抽象业务逻辑函数 )(一)
【C 语言】二级指针作为输入 ( 自定义二级指针内存 | 二级指针排序 | 抽象业务逻辑函数 )(一)
147 0