Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] event delegation order
- From: anthony at chovy.com (Anthony Ettinger)
- Subject: [Javascript] event delegation order
- Date: Wed May 2 14:57:44 2007
I'm reading through PPK's article at: http://www.quirksmode.org/js/events_order.html Near the bottom, there is an explanation of currentTarget with 2 event handlers registered...I'm confused here how and why clicking on element2 would trigger the event handler twice. Here is an excerpt: ------------------------------------ | document | | --------------- ------------ | | | element1 | | element2 | | | --------------- ------------ | | | ------------------------------------ element1.onclick = doSomething; element2.onclick = doSomething; document.onclick = defaultFunction; ..... 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)? -- Anthony Ettinger Ph: 408-656-2473 http://chovy.dyndns.org/resume.html http://utuxia.com/consulting
- Follow-Ups:
- [Javascript] event delegation order
- From: Nick Fitzsimons
- [Javascript] event delegation order
- Prev by Date: [Javascript] calling onmouseout on table element
- Next by Date: [Javascript] event delegation order
- Previous by thread: [Javascript] calling onmouseout on table element
- Next by thread: [Javascript] event delegation order
- Index(es):