Advertisement
DarthAT

Hotwheel java

Jan 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Get the modal
  2. var modal = document.getElementById('myModal');
  3.  
  4. // Get the image and insert it inside the modal - use its "alt" text as a caption
  5. var img = document.getElementById('myImg');
  6. var modalImg = document.getElementById("img01");
  7. var captionText = document.getElementById("caption");
  8. img.onclick = function(){
  9.     modal.style.display = "block";
  10.     modalImg.src = this.src;
  11.     captionText.innerHTML = this.alt;
  12. }
  13.  
  14. // Get the <span> element that closes the modal
  15. var span = document.getElementsByClassName("close")[0];
  16.  
  17. // When the user clicks on <span> (x), close the modal
  18. span.onclick = function() {
  19.   modal.style.display = "none";
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement