|
@@ -1,48 +0,0 @@
|
|
-<!DOCTYPE html>
|
|
|
|
-<html lang="en">
|
|
|
|
-<head>
|
|
|
|
- <meta charset="UTF-8">
|
|
|
|
- <title>Title</title>
|
|
|
|
-</head>
|
|
|
|
-<body>
|
|
|
|
-<script type="text/javascript">
|
|
|
|
- //将图片名称放到数组中
|
|
|
|
- let imgObj = {
|
|
|
|
- imgs:["images/1.png","images/2.png","images/3.png"]
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- let num = 0;//数组的下标,0-2
|
|
|
|
- function prev(){
|
|
|
|
- //1)找到img标签
|
|
|
|
- let imgEle = document.getElementsByTagName("img")[0];
|
|
|
|
- //2、给img标签的SRC属性赋值
|
|
|
|
- num--;
|
|
|
|
- //从后面重新开始展示图片
|
|
|
|
- if(num<0){
|
|
|
|
- num = 2;
|
|
|
|
- }
|
|
|
|
- let url = imgObj.imgs[num];
|
|
|
|
- imgEle.src=url;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function next(){
|
|
|
|
- //1)找到img标签
|
|
|
|
- let imgEle = document.getElementsByTagName("img")[0];
|
|
|
|
- //2、给img标签的SRC属性赋值
|
|
|
|
- num++;
|
|
|
|
- //从前面重新开始展示图片
|
|
|
|
- if(num>2){
|
|
|
|
- num = 0;
|
|
|
|
- }
|
|
|
|
- let url = imgObj.imgs[num];
|
|
|
|
- imgEle.src=url;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-</script>
|
|
|
|
-<button style="height: 150px;width: 50px" onclick="prev()"> < </button>
|
|
|
|
-
|
|
|
|
-<img src="images/1.png" width="600px" height="450px" style="position: relative;top:70px">
|
|
|
|
-
|
|
|
|
-<button style="height: 150px;width: 50px" onclick="next()"> > </button>
|
|
|
|
-</body>
|
|
|
|
-</html>
|
|
|