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

78 views Asked by At

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?

1

There are 1 answers

0
nonopolarity On BEST ANSWER

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".