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 = $(".myImg");
6 var modalImg = document.getElementById("img01");
7 var captionText = document.getElementById("caption");
8 function image(event) {
9 modal.style.display = "block";
10 modalImg.src = event.target.src;
11 captionText.innerHTML = event.target.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 }
21