Created
July 1, 2025 19:21
-
-
Save SomeNiceCode/781934f08a3f3d7e518d8e12ffa39a66 to your computer and use it in GitHub Desktop.
Dz events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const images = [ | |
"https://bigfoto.name/uploads/posts/2022-01/1641988718_10-bigfoto-name-p-polirovannii-beton-v-interere-22.jpg", | |
"https://tse2.mm.bing.net/th/id/OIP.GhCdwqjnQ_4lDbolnBlTRgHaEK?rs=1&pid=ImgDetMain&o=7&rm=3", | |
"https://klike.net/uploads/posts/2019-11/1574510006_2.jpg" | |
]; | |
let currentIndex = 0; | |
const imgElement = document.getElementById("gallery-image"); | |
const prevButton = document.getElementById("prev-button"); | |
const nextButton = document.getElementById("next-button"); | |
function updateGallery() { | |
imgElement.src = images[currentIndex]; | |
prevButton.disabled = currentIndex === 0; | |
nextButton.disabled = currentIndex === images.length - 1; | |
} | |
prevButton.addEventListener("click", () => { | |
if (currentIndex > 0) { | |
currentIndex--; | |
updateGallery(); | |
} | |
}); | |
nextButton.addEventListener("click", () => { | |
if (currentIndex < images.length - 1) { | |
currentIndex++; | |
updateGallery(); | |
} | |
}); | |
updateGallery(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment