30. Browser events
To make our recipes into a web application we need to respond to user events. To do that, we have to understand what happens when you poke the browser.
The browser detects user interaction and generates (or “fires”) a corresponding event object: click, change, select, scroll, etc. (There’s a more complete list in Appendix B, Browser events.)
The event contains details about the interaction: key pressed, mouse button clicked, etc. (Exactly what it contains depends on the kind of event.)
The browser looks for code to handle the event. It looks on the element where the event occurred (the button or scroll bar or input field, for example), then its parent, then its grand parent, etc. This is called “bubbling” up.
Anywhere it finds an “event handler”, it runs that code.