[jQuery] Reference to the element that triggered the event(Karl Rudd)

[jQuery] Reference to the element that triggered the event(Karl Rudd)

Many thanks (and to Brian and Aaron for their answers too).
Perfect.
-----Original Message-----
From: discuss-bounces@jquery.com [mailto:discuss-bounces@jquery.com] On
Behalf Of Karl Rudd
Sent: 13 March 2007 09:06
To: jQuery Discussion.
Subject: Re: [jQuery] Reference to the element that triggered the event(Karl
Rudd)
Aaah, :) That's a different kettle of fish. You'll want to look at the
event's "target" member.
If we use your "pseudo-HTML" and this code:
$(".selectable").click( function(e) {
alert( e.target.nodeName.toLowerCase() );
});
If you click the image it should alert 'img'.
Note that if you click one of the "raw" text nodes inside the
.selectable the target will be the .selectable.
Karl Rudd

















    • Topic Participants

    • jc