Now that you’re a pro at data updates, transitions, and motion, let’s incorporate true interactivity.
Say what? I know, I know. First, we bound data, which was weird enough. And now I’m talking about binding event listeners?
To make our pieces interactive, we define chunks of code that listen for specific events being triggered on specific DOM elements. In Chapter 9, we used the following code:
//Do something on click
This binds an event listener to the
p paragraph element. The listener happens to be listening for the
click. The events supported vary somewhat by browser. Peter-Paul Koch’s event compatibility tables are a useful reference.)