javascript里的document.all用法
1
、理解document.all
[]
从IE4开始IE的object
model才增加了document.all
[],来看看document.all
[]的Description:
Array
of all HTML tags in the document.Collection of all elements contained by the
object.
也就是说document.all
[]是文档中所有标签组成的一个数组变量,包括了文档对象中所有元素(见例1)。
IE’s
document.all
collection exposes all document elements.This array provides access to every
element in the document.
document.all
[]这个数组可以访问文档中所有元素。
例1(这个可以让你理解文档中哪些是对象)
<!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>
<title>Document.All
Example</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>
输出结果:
Example Heading
This is a paragraph
. It is only a paragraph.
Yet another paragraph.
This final paragraph
has special
emphasis.
< type="text/javascript">
<!--
var i,origLength;
origLength = document
相关文档:
1、问题背景:
在做项目时候遇到一个小小的显示客户部门名称(拼音)的业务,就是在部门名称下有相应的拼音,而在现有的数据库中没有相应字段,并且部门数量比较多,添加起来比较费时,就想能否在js中实现,在页面中处理。
2、原理描述
程序原理很简单,网上可以找到汉字拼音的数据字典,但是由于大家都知道GB2312编码里 ......
Link:http://topic.csdn.net/u/20100317/15/687e21bc-40f3-4f0e-bc22-5f2a32ceb1a3.html?seed=1664090183&r=63989333#r_63989333
<HTML>
<head>
<title>sample</title>
<mce:script language="JavaScript"><!--
var c="FFFFFF";
window.onload=function (){
setInterval(s ......
// JavaScript 脚本,解析型语言
//
var ABCD = function(){
var pub = {};
var pri = {};
pri.name = "myhere";
pri.age = 23;
//var ABCDE;
pub.setName = function( newName){
pri.name = newName;
};
// 这里 pub.getName 被赋值为一个函数,就是定义一个函数
// 这个函数并没有运行,这个函数 ......
本文转自:http://www.w3school.com.cn/js/jsref_tofixed.asp
定义和用法
toFixed() 方法可把 Number 四舍五入为指定小数位数的数字。
语法
NumberObject.toFixed(num)
参数num描述必需。规定小数的位数,是 0 ~ 20 之间的值,包括 0 和 20,有些实现可以支持更大的数值范围。如果省略了该参数,将用 0 代替。
......