Javascript照片幻灯片代码

时间:2017-04-24 02:48:37

标签: javascript html webpage

此代码来自W3schools的照片幻灯片,我只想知道每行的含义及其作用。谢谢。

<script>
var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
showSlides(slideIndex += n);
}

function currentSlide(n) {
showSlides(slideIndex = n);
}

function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
if (n > slides.length) {slideIndex = 1}    
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
  slides[i].style.display = "none";  
}
slides[slideIndex-1].style.display = "block";  
}
</script>

0 个答案:

没有答案