开发者

What is a good example to listen to event both at the "link" (or div) and at the parent or ancestor element?

Most of the time I see code registering an event listener for a link or a div or button, and handle everything from there. But the event capturing and bubbling is good to handle开发者_开发问答 events at the offspring and then at the ancestor level. But what is a good example we will want to listen at 2 different places?


I saw an example in a book:

if you are designing a "whack a mole" game, you want to listen to the event of the mole div to know of a "hit" and the empty space in the parent div, so as to know a "miss".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜