Undefined Image src Model popup : I'm making a Image Gallery with model popup, The JavaScript code is working, but Undefined Image src of the gallery popup modal box. What mistake i did? Any Help is Greatly Appreciated, thanks.


    <?php echo '<img id="myImg" src="'.esc_url( $info['0'] ).'" onclick="imgPopup();" alt="Snow" style="width:100%;max-width:300px">'; ?>
    
    
    function imgPopup(){
    var modal = document.getElementById('myModal');
    var modalImg = document.getElementById("myImg1");
    modal.style.display = "block";
    modalImg.src = this.src;
    
    var span = document.getElementsByClassName("close")[0];
    span.onclick = function() { 
        modal.style.display = "none";
    } }