How to get the img src without id?

Help!
Need to get the img src and record in a variable. The problem is that you cannot use id, when you click on the picture you need to get it scr.
<div class="wrapper-offer">
 <div class="wrap-galery offer-galery" onclick="src()">
 <img src="img/galery-white-1.jpg" id ="boots_one" alt="" class="offer-galery">
</div>
 <div class="wrap-galery offer-galery" onclick="src()">
 <img src="img/galery-white-2.jpg" id ="boots_two" alt="" class="offer-galery">
</div>
 <div class="wrap-galery offer-galery" onclick="src()">
 <img src="img/galery-white-3.jpg" id ="boots_three" alt="" class="offer-galery" >
</div>
 </div>


Need help with JS, I tried that and nothing happened
var img
function src(){
 img = $(this).attr('src');
alert(img);
}
March 23rd 20 at 19:12
1 answer
March 23rd 20 at 19:14
Solution
document.addEventListener('click', function(evt) {
 if (evt.target.matches('img')) {
alert(evt.target.src)
}
})

Find more questions by tags HTML