kuchuz

Tugas 3 PWEB-D main.js

Oct 27th, 2021
628
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var slideIndex = 1;
  2. showSlides(slideIndex);
  3.  
  4. // Next/previous controls
  5. function plusSlides(n) {
  6.     showSlides(slideIndex += n);
  7. }
  8.  
  9. // Thumbnail image controls
  10. function currentSlide(n) {
  11.     showSlides(slideIndex = n);
  12. }
  13.  
  14. function showSlides(n) {
  15.     var i;
  16.     var slides = document.getElementsByClassName("mySlides");
  17.     var dots = document.getElementsByClassName("dot");
  18.     if (n > slides.length) {
  19.         slideIndex = 1
  20.     }
  21.     if (n < 1) {
  22.         slideIndex = slides.length
  23.     }
  24.     for (i = 0; i < slides.length; i++) {
  25.         slides[i].style.display = "none";
  26.     }
  27.     for (i = 0; i < dots.length; i++) {
  28.         dots[i].className = dots[i].className.replace(" active", "");
  29.     }
  30.     slides[slideIndex - 1].style.display = "block";
  31.     dots[slideIndex - 1].className += " active";
  32. }
RAW Paste Data