interfaces/topic_4/example2/script.js

28 lines
537 B
JavaScript
Raw Normal View History

2023-04-07 05:21:44 +00:00
let slideIndex = 1;
showSlides(slideIndex);
function nextSlide() {
showSlides(slideIndex += 1);
}
function previousSlide() {
showSlides(slideIndex -= 1);
}
function showSlides(n) {
let slides = document.getElementsByClassName("slider-line")[0].getElementsByTagName("img");
if (n > slides.length) {
slideIndex = 1
}
if (n < 1) {
slideIndex = slides.length
}
for (let slide of slides) {
slide.style.display = "none";
}
slides[slideIndex - 1].style.display = "block";
}