-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (28 loc) · 742 Bytes
/
index.js
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
let prev = document.getElementById("prev");
let next = document.getElementById("next");
let arr = ["imagees/img1.jpg", "imagees/img2.jpg", "imagees/img3.jpg", "imagees/img4.jpg", "imagees/img5.jpg", "imagees/img6.jpg"]
let i = 0;
next.addEventListener("click", function () {
i++;
if (i > arr.length - 1) {
i = 0;
}
document.getElementById("image").src = arr[i];
})
prev.addEventListener("click", function (){
i--;
if (i < 0) {
i = arr.length - 1;
}
document.getElementById("image").src = arr[i];
})
function slides() {
document.getElementById("image").src = arr[i];
if (i < arr.length - 1) {
i++;
}
else {
i = 0;
}
}
setInterval(slides, 2000);