jQuery click event on parent, but finding the child (clicked) element
Posted
by
Mahdi
on Stack Overflow
See other posts from Stack Overflow
or by Mahdi
Published on 2012-10-06T09:33:28Z
Indexed on
2012/10/06
9:37 UTC
Read the original article
Hit count: 272
let say I have a parent element which has so many nested child elements inside of itself:
<div id="p">
<div id="c1">
<div id="c2"></div>
<div id="c3"></div>
</div id="c4">
<div id="c5"></div>
</div>
</div>
I've already bind a click
event on the parent:
$('#p').bind('click', function() {
alert($(this).attr('id'));
});
Because the event is assigned to the parent element, I always see the parent id, however, I'm wondering if there is any possible way to find out which of this child elements has been clicked?
I also can't assign any event to the child elements or remove the event listener from parent div.
© Stack Overflow or respective owner