数组对象
创建数组的三种方法:
new Array(); 创建一个空数组,一般在循环中应用
new Array(10);
new Array("a","b","c");
创建一个二维数组
var arr = new Array(4);
for (var i=0;i<4;i++);
arr[i]=new Array(6);
常用属性 length:返回数组中元素的个数
JS实例:实现等待注册
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站的注册协议</title>
</head>
<body>
请仔细阅读注册协议:<br>
<textarea cols="40" rows="7">
注册协议,请阅读。
</textarea>
<br>
<input type="button" disabled="disabled" id="button1" value=" 10 " />
</body>
</html>
<script language="javascript" type="text/javascript">
function kanyx(){
//1、获取按钮的文字
var btn_num=document.getElementById("button1").value;
//2、每次减1
if(parseInt(btn_num)>0){
//3、当这个数等于0的时候,设置这个按钮可以用,并且 显示"同意"
document.getElementById("button1").value = btn_num-1;
var t= setTimeout("kanyx()",1000);
}else{
//设置按钮的文本
document.getElementById("button1").value=" 我同意 ";
//设置按钮可用
document.getElementById("button1").disabled=false;
}
}
kanyx();
</script>
JavaScript浏览器对象 window
window 窗口对象 history document location
location 地址对象 link form anchor
document 文档对象
form 表单对象
注意:关于DIV的定位问题
position: absolute 绝对位置
relative 相对位置