-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (31 loc) · 993 Bytes
/
Copy pathapp.js
File metadata and controls
36 lines (31 loc) · 993 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
images = document.querySelectorAll("main img");
imagesArray = Array.from(images);
currentIndex = 0;
setInterval(() => {
nextImage();
}, 3000);
const nextImage = function () {
console.log(imagesArray);
if (currentIndex == 2) {
imagesArray[0].classList.add("active");
imagesArray[2].classList.remove("active");
currentIndex = 0;
} else {
imagesArray[currentIndex + 1].classList.add("active");
imagesArray[currentIndex].classList.remove("active");
currentIndex++;
}
// for (let index = 0; index < imagesArray.length; index++) {
// // console.log(imagesArray[index]);
// if (index == imagesArray.length - 1) {
// index = 0;
// console.log("last index");
// }
// if (imagesArray[index].classList.contains("active")) {
// console.log("i am active");
// imagesArray[index].classList.remove("active");
// imagesArray[index + 1].classList.add("active");
// break;
// }
// }
};