In html I have some images with same class name but different ids.
<IMG STYLE="position:absolute; TOP:35px; LEFT:170px; WIDTH:25px; HEIGHT:20px; background:red;" SRC="../image_collection/xx.png" class="allBtns" id="btn1">
<IMG STYLE="position:absolute; TOP:95px; LEFT:50px; WIDTH:25px; HEIGHT:20px; background:red;" SRC="../image_collection/yy.png" class="allBtns" id="btn2">
<IMG STYLE="position:absolute; TOP:295px; LEFT:250px; WIDTH:25px; HEIGHT:20px; background:red;" SRC="../image_collection/yy.png" class="allBtns" id="btn3">
..........
If i click an image I want the ID of the image that has been clicked.
I have tried the following by it returns full list of ids:
$(".allBtns").on("click", function(event)
{
var ids = $('.allBtns').map(function() {
return this.id;
}).get();
alert(ids);
})
How do I get the image ID that's been clicked?