How can i know which div click event has been triggered using Jquery Here is the fiddler link Click Here. Actually I am dynamically generating the div in my placeholder I dont know how can i know which div has been clicked ?
2 Answers
you can get this by checking this like
$(".nailthumb-container").click(function () {
alert($(this).attr("id"));
//alert(this.id); //you can also try this
alert('Hii');
});
and if you want to get who trigger this event, you can get the target like, here place e, which will capture the event object.
$(".nailthumb-container").click(function (e) {
alert(e.target.id);
alert('Hii');
});
Comments
well you can simple do it using this
this will give you object of div on which you have clicked
$(".nailthumb-container").click(function () {
alert($(this).attr('id'));
});