Advertisement
Aguezz

UMPTKIN - js custom zoomable image

May 28th, 2023
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. function zoomImage(e) {
  2. // Get the modal
  3. var modal = document.querySelector(".modal-image");
  4. var modalImg = modal.querySelector(".modal-content");
  5.  
  6. console.log(modal, modalImg);
  7.  
  8. modal.style.display = "block";
  9. modalImg.src = e.target.src;
  10.  
  11. // Get the <span> element that closes the modal
  12. var span = modal.querySelector(".close");
  13.  
  14. // When the user clicks on <span> (x), close the modal
  15. span.onclick = function () {
  16. modal.style.display = "none";
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement