-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (26 loc) · 882 Bytes
/
script.js
File metadata and controls
30 lines (26 loc) · 882 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
const images = [
"providencia1.jpg",
"providencia2.jpg",
"providencia3.jpg",
"providencia.jpg",
"providencia4.jpg",
"providencia5.jpg",
];
let currentImageIndex = 0;
console.log(images);
const prevButton = document.querySelector("#prev-button");
const nextButton = document.querySelector("#next-button");
const img = document.querySelector("img");
prevButton.addEventListener("click", function () {
currentImageIndex =
currentImageIndex === 0 ? images.length - 1 : currentImageIndex - 1;
img.src = images[currentImageIndex];
});
nextButton.addEventListener("click", function () {
currentImageIndex = (currentImageIndex + 1) % images.length;
img.src = images[currentImageIndex];
});
const darkLightButton = document.querySelector("#dark-light-button");
darkLightButton.addEventListener("click", function () {
document.body.classList.toggle("dark");
});