modal multiple images

Solutions on MaxInterview for modal multiple images by the best coders in the world

showing results for - "modal multiple images"
Kali
12 Sep 2016
1var modal = document.getElementById("myModal");
2var i;
3
4var img = document.getElementsByClassName("myImg");
5var modalImg = document.getElementById("img01");
6
7 for(i=0;i< img.length;i++)
8   {    
9    img[i].onclick = function(){
10
11    modal.style.display = "block";
12       modalImg.src = this.src;
13
14 }
15}
16
17var span = document.getElementsByClassName("close")[0];
18
19
20span.onclick = function() { 
21   modal.style.display = "none";
22}
23