Re: Clarification on mouseenter/mouseleave

   On 1/07/10 1:44 PM, Joćo Eiras wrote:
> On , Sean Hogan <shogun70@westnet.com.au> wrote:
>
>>   On 1/07/10 12:33 PM, Joćo Eiras wrote:
>>>
>>>>>> Looks like it.
>>>>>> And the W3C DOM model won't haven't an equivalent to fromElement
>>>>>> - for
>>>>>> mouseleave - and toElement - for mouseenter. I can't see a need for
>>>>>> them, but would be nice to know how they are being used on the web.
>>>>>>
>>>>>
>>>>> There is, it's relatedTarget.
>>>>>
>>>>
>>>> For mouseleave, relatedTarget is equivalent to toElement.
>>>> For mouseenter, relatedTarget is equivalent to fromElement.
>>>>
>>>
>>> Oh, you mean target then.
>>>
>>>
>>
>> target is the equivalent of srcElement.
>>
>
> Not really. target is srcElement for all events but
> mouseenter/leave/over/out. These these last ones, it's either
> toElement and fromElement.
>

That doesn't sound right, but I might not be understanding what you are 
saying.

I've attached a modified version of your test page.
It logs the srcElement, fromElement, toElement and 'this' element for 
every mouseenter / mouseleave (works on IE only).
If you hover the inner "DIV" element *without* passing through the outer 
"DIV" you can see that both outer and inner receive a mouseenter event 
(in that order), srcElement is always equivalent to 'this' element 
(first it is outer, then inner), fromElement is always the body, and 
toElement is always the inner "DIV".

Now, for W3C mouseenter events:
- target is equivalent of srcElement
- relatedTarget is equivalent of fromElement
- there is no equivalent of toElement

Received on Thursday, 1 July 2010 10:36:31 UTC