-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcycle_diagram.html
More file actions
49 lines (43 loc) · 1.5 KB
/
cycle_diagram.html
File metadata and controls
49 lines (43 loc) · 1.5 KB
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
44
45
46
47
48
49
<!--
* @由于个人水平有限, 难免有些错误, 还请指点:
* @Author: cpu_code
* @Date: 2020-10-19 16:01:32
* @LastEditTime: 2020-10-19 16:08:58
* @FilePath: \web\javascript\cycle_diagram\cycle_diagram.html
* @Gitee: [https://gitee.com/cpu_code](https://gitee.com/cpu_code)
* @Github: [https://github.com/CPU-Code](https://github.com/CPU-Code)
* @CSDN: [https://blog.csdn.net/qq_44226094](https://blog.csdn.net/qq_44226094)
* @Gitbook: [https://923992029.gitbook.io/cpucode/](https://923992029.gitbook.io/cpucode/)
-->
<!DOCTYPE html>
<html lang="ch">
<head>
<meta charset="UTF-8">
<title>轮播图</title>
</head>
<body>
<img id="image" src="image/banner_1.jpg" width="100%">
<script>
/*
分析:
1.在页面上使用img标签展示图片
2.定义一个方法,修改图片对象的src属性
3.定义一个定时器,每隔1秒调用方法一次。
*/
//修改图片src属性
var number = 1;
function fun(){
number++;
//判断number是否大于3
if(number > 3){
number = 1;
}
//获取img对象
var image = document.getElementById("image");
image.src = "image/banner_" + number + ".jpg";
}
//2.定义定时器
setInterval(fun, 1000);
</script>
</body>
</html>