event.currentTarget is the element the event was attached to (i.e.
it's equivalent to "this").
event.target == event.srcElement is the element that triggered the
event.

So for example:

<ul id="myUl">
  <li id="myLi">click me</li>
</ul>

$('myUl').observe('click', callback);

If I now click on the click me text: event.target should be (if
following the specs) li#myLi and event.currentTarget should be
ul#myUl.



On Jun 13, 7:38 pm, "Mislav Marohnić" <[EMAIL PROTECTED]>
wrote:
> Thanks for the report. This sounds serious enough to open up a ticket, can
> you do that?
>
> While we're at it, does anyone really know the difference between "target"
> and "currentTarget"? Doesn't one of them correspond to what the "this"
> keyword references when the event handler is executed?
>
> On 6/13/07, jdalton <[EMAIL PROTECTED]> wrote:
>
> > Hi Guys,
>
> > I was using Event.element(event) in an image onload observer and I
> > noticed that in IE,
> > it would return the Image element while in FireFox it would return a
> > [object HTMLDocument].
>
> > I used the guts of the Event.element and changed it to $
> > (event.currentTarget || event.srcElement)
> > and that fixed it.
>
> > This is probably an edge case.
>
> > More info about event targets can be found here.
> >http://developer.mozilla.org/en/docs/DOM:event:Comparison_of_Event_Ta...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to