Tippon

Untitled

Aug 11th, 2023
1,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.17 KB | None | 0 0
  1.  
  2. <div class="MainPoster">
  3.         <!-- The Modal -->
  4. <img class="myImages" id="myImg" src="images/2023 Lineup Poster v1.webp" alt="Cwmfest 2023 Full Lineup" style='height: 100%; width: 100%; object-fit: contain' >
  5.  
  6. <div id="myModal" class="modal">
  7.   <span class="close">&times;</span>
  8.   <img class="modal-content" id="img01">
  9.   <div id="caption"></div>
  10. </div>
  11.  
  12. <script>
  13. // create references to the modal...
  14. var modal = document.getElementById('myModal');
  15. // to all images -- note I'm using a class!
  16. var images = document.getElementsByClassName('myImages');
  17. // the image in the modal
  18. var modalImg = document.getElementById("img01");
  19. // and the caption in the modal
  20. var captionText = document.getElementById("caption");
  21.  
  22. // Go through all of the images with our custom class
  23. for (var i = 0; i < images.length; i++) {
  24.  var img = images[i];
  25.  // and attach our click listener for this image.
  26.  img.onclick = function(evt) {
  27.    modal.style.display = "block";
  28.    modalImg.src = this.src;
  29.    captionText.innerHTML = this.alt;
  30.  }
  31. }
  32.  
  33. var span = document.getElementsByClassName("close")[0];
  34.  
  35. span.onclick = function() {
  36.  modal.style.display = "none";
  37. }
  38. </script>
  39. </div>
  40.  
Advertisement
Add Comment
Please, Sign In to add comment