I am trying to figure out if its possible to access a child target element from a parent event handler once the opportunity to handle the event has passed on the child element. For instance, if I had the following markup:
<a id="link1" href="#">Link to table of contents</a>
<a id="link2" href="#">Link to chapters</a>
<a id="link3" href="#">Link to appendix</a>
$content = $('#content');
// how can I find the innermost target which triggered the click event?
I want to be able to access the <a> element that triggered the original click event. But instead of passing a separate function to each jQuery .click() method for "each" <a> I simply want to allow all 3 <a> event handlers to bubble up to the parent <div id="content"> and find out which <a> was clicked from the parent event handler and handle any of the 3 <a> click events from the 1 parent event handler. How would I do this...do I use the Event parameter to find this reference?
Thanks for reading
39 views and no help? I guess I'll have to answer my own question. I think I have the correct answer:
Not sure how I missed this in the beginning. I guess I couldn't see the forest because of the trees in the way.
var tgt = e.target;
This topic is now closed. New replies are no longer allowed.