Answers for "modal multiple images"

0

modal multiple images

var modal = document.getElementById("myModal");
var i;

var img = document.getElementsByClassName("myImg");
var modalImg = document.getElementById("img01");

 for(i=0;i< img.length;i++)
   {    
    img[i].onclick = function(){

    modal.style.display = "block";
       modalImg.src = this.src;

 }
}

var span = document.getElementsByClassName("close")[0];


span.onclick = function() { 
   modal.style.display = "none";
}
Posted by: Guest on December-13-2020

Code answers related to "modal multiple images"

Code answers related to "Javascript"

Browse Popular Code Answers by Language