-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst_javascript.html
More file actions
43 lines (38 loc) · 941 Bytes
/
Copy pathfirst_javascript.html
File metadata and controls
43 lines (38 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- js <script src="index.js"></script> -->
<title>JavaScript</title>
</head>
<body>
<h1 id="box1">这个是我的第一JavaScript程序。</h1>
<h1 id="box2">这个是我的第二JavaScript程序。</h1>
<button type="button" onclick="displayDate()">显示日期</button>
<script type="text/javascript">
//获取对象固定语法
var object1 = document.getElementById("box2");
//数组:有序的数据结构
var colors = ['red','green','blue','yellow'];
//修改颜色对象
var i = 0;
object1.style.color = colors[1];
//alert(box1.innerHTML);
var i = -1;
function F() {
if (i>4){
i = -1;
}
i = i + 1;
object1.style.color =colors[i];
}
setInterval(F,500); //每0.5秒调用F函数
//setInterval(F(),500);//立即调用
function displayDate()
{
document.getElementById("box1").innerHTML=Date();
}
//setInterval(displayDate,1000) 直接显示时间
</script>
</body>
</html>