Hi, please help!
This is the code for a manual slideshow, it’s working but I wanted to stop at the last img/div, but I don’t undestand the javascript code, (I’m suppose to know this), please, anybody can you explain it to me!!!
(I cleaned the code to be easy to followed)
<div class="slideshow-container">
<div class="mySlides fade">
<img src="img_nature_wide.jpg" style="width:100%">
</div>
<div class="mySlides fade">
<img src="img_snow_wide.jpg" style="width:100%">
</div>
<div class="mySlides fade">
<img src="img_mountains_wide.jpg" style="width:100%">
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
//Arrows
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
<script>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex = slideIndex + n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var slides = document.getElementsByClassName("mySlides");
if (n > 3) {
slideIndex = 1
}
if (n < 1) {
slideIndex = 3
}
slides[0].style.display = "none";
slides[1].style.display = "none";
slides[2].style.display = "none";
slides[slideIndex - 1].style.display = "block";
}
</script>