O'Reilly logo
  • Ahmed Elgendy thinks this is interesting:

How to reuse the same handler for all the images

Clearly writing a handler for each image isn’t a good way to solve this problem. So what we’re going to do instead is use our existing handler, showAnswer, to handle all of the click events for all the images. Of course, we’ll need to modify showAnswer a little bit to make this work. To use

From

Cover of Head First JavaScript Programming

Note

How to make the handler function work for every element intended?