Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] event delegation order
- From: nick at nickfitz.co.uk (Nick Fitzsimons)
- Subject: [Javascript] event delegation order
- Date: Wed May 2 15:25:14 2007
On 2 May 2007, at 20:57:26, Anthony Ettinger wrote: > http://www.quirksmode.org/js/events_order.html > > <snip> >> ------------------------------------ >> | document | >> | --------------- ------------ | >> | | element1 | | element2 | | >> | --------------- ------------ | >> | | >> ------------------------------------ >> >> element1.onclick = doSomething; >> element2.onclick = doSomething; >> document.onclick = defaultFunction; <snip> >> But suppose we register these event handlers: >> >> element1.onclick = doSomething; >> element2.onclick = doSomething; >> >> If the user clicks on element2 doSomething() is executed twice. > ======== > > WHY is doSomething() called twice from element2 if element1 is a > sibling (not an ancestor/child)? It is rather unclear, but I believe at that point he's gone back to referring to the original diagram, where element1 was a child of element2. Seen in that context, it should make sense. It's possible the two parts got separated when the article was edited. You might want to contact ppk (there's a "Contact" link at the bottom of the page) to point out that the article is unclear at that point - he's very committed to providing accurate information, and I'm sure he would welcome the opportunity to clarify the article. Regards, Nick. -- Nick Fitzsimons http://www.nickfitz.co.uk/
- References:
- [Javascript] event delegation order
- From: Anthony Ettinger
- [Javascript] event delegation order
- Prev by Date: [Javascript] event delegation order
- Next by Date: [Javascript] calling onmouseout on table element
- Previous by thread: [Javascript] event delegation order
- Next by thread: [Javascript] automatic filling of login field
- Index(es):