Guest User

Untitled

a guest
May 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <div class="w3-section">
  2. <button class="w3-btn" onclick="plusDivs(-1)"><h6> Prev Image<h6/></button>
  3. <button class="w3-btn" onclick="plusDivs(1)"><h6>Next Image<h6/> </button><h6/>
  4. </div>
  5. </div>
  6.  
  7.  
  8.  
  9.  
  10. <script>
  11. var slideIndex = 1;
  12. showDivs(slideIndex);
  13.  
  14. function plusDivs(n) {
  15. showDivs(slideIndex += n);
  16. }
  17.  
  18. function currentDiv(n) {
  19. showDivs(slideIndex = n);
  20. }
  21.  
  22. function showDivs(n) {
  23. var i;
  24. var x = document.getElementsByClassName("mySlides");
  25. var dots = document.getElementsByClassName("demo");
  26. if (n > x.length) {slideIndex = 1}
  27. if (n < 1) {slideIndex = x.length}
  28. for (i = 0; i < x.length; i++) {
  29. x[i].style.display = "none";
  30. }
  31. for (i = 0; i < dots.length; i++) {
  32. dots[i].className = dots[i].className.replace(" w3-red", "");
  33. }
  34. x[slideIndex-1].style.display = "block";
  35. dots[slideIndex-1].className += " w3-red";
  36. }
  37.  
  38. window.onload = function() {
  39. var image = document.getElementById("img");
  40.  
  41. function updateImage() {
  42. image.src = image.src.split("?")[0] + "?" + new Date().getTime();
  43. }
  44.  
  45. setInterval(updateImage, 1000);
  46. }
  47. </script>
Add Comment
Please, Sign In to add comment