images from table into Modal

I have a large table of RAF losses in WW2. My plan is to have small size images inside the table beside names. I want to click on the small images and have them open in modal. I have tried so many ways with no success. querySelectorAll doesn’t seem to find images in table nor does any other method I have tried. I do not know much about java or jquery, I make these pages to honour men lost. I can send the whole HTML page if that might help. I am really at a loss… this is about 3 weeks of trying things… with no joy. Any help most appreciated. contact directly if need… dswallow4 ‘at’… Thanks Dave

var tbl = document.getElementById(‘dataTable’);
var modal = document.getElementById(‘myModal’);
var images = document.querySelectorAll(".myImg");
var modalImg = document.getElementById(‘modal-image’);
var captionText = document.getElementById(“alt”);
for(let i = 0; i < images.length; i++){
images[i].onclick = function(){ = “block”;
modalImg.src = this.src;
captionText.innerHTML = this.alt;

Can you post a link to your full HTML page? I wonder if the code is running too early!