Advertisement
nosthemerc

basic slideshow

Aug 3rd, 2020
1,411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const images = document.getElementsByClassName("gallery-images");
  2. var count = 1;
  3. var imageCount = document.getElementById(count);
  4.  
  5. function refreshImage() {
  6.     for (i = 0; i < images.length; i++) {
  7.         images[i].style.display = "none";
  8.     }
  9.     imageCount.style.display = "block";
  10. }
  11.  
  12. function previousImage() {
  13.     count--;
  14.     refreshImage();
  15.     if (count < 1) {
  16.         count = images.length
  17.     }
  18. }
  19.  
  20. function nextImage() {
  21.     count++;
  22.     refreshImage();
  23.     if (count > images.length) {
  24.         count = 1
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement