简体   繁体   中英

What's the event.target when the handler function is invoked during capturing and bubbling phase?

As in the following example, when I click on the red div, the three alerts all shows that the event target is the div element, even though the handler function is actually registered on the containing document element. So I predict that the event target is always the most specific element? Is there official document dedicated to explaining this ?

http://jsbin.com/duzeqejoki/edit?html,css,js,output

It depends.. if you're using direct JS, it should be the most specific target of the registered event that bubbles up.

If you're using a framework or toolkit to handle or simplify event registrations, this may be modified to normalize behavior to the dom node the event was registered for, so that you can have more consistent expectations. YMMV.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM