I have 3 images, each one with the same id/class (i have tried both) and on click i want to get the src of the image i click on, instead i get the src of the first image
I have tried using Id's, Classes, the img element, this. and nothing seems to work
Theres more code in the parents of the element, but its all for appearnce
HTML
<img src="_IMAGE_SRC_" class="card-img-top img-fluid webImg"/>
<img src="_IMAGE_SRC_" class="card-img-top img-fluid webImg"/>
<img src="_IMAGE_SRC_" class="card-img-top img-fluid webImg"/>
JavaScript
$('.webImg').on('click', () =>{
let imgSrc = $(".webImg").attr('src')
console.log(imgSrc);
})
I have multiple images, and i want to get the image src so that when i click on it, a model comes up, i then use the variable to populate the image inside the modal