0

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?

nonopolarity
  • 146,324
  • 131
  • 460
  • 740
  • Do you *need* to listen at both places? You can check the target when listening at an ancestor, would this do the job? – Nick Craver Jun 21 '10 at 10:46
  • most of the time i see code listening at the most specific element (the deepest offspring), and handle everything there. – nonopolarity Jun 21 '10 at 10:59

1 Answers1

0

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

nonopolarity
  • 146,324
  • 131
  • 460
  • 740