0

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 2

1

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');
});
Sign up to request clarification or add additional context in comments.

Comments

1

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'));
});​

Demo

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.