JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
Click me!
<img id="firstIMG">
<img id="secondIMG">
</div>
JavaScript
$(document).on("click", ".container", function(){
var img = $(this).find("img"), // select images inside .container
len = img.length; // check if they exist
if( len > 0 ){
// images found, get id
var attrID = img.first().attr("id"); // get id of first image
alert(attrID);
} else {
// images not found
}
});