8 EVENT-BASED PROGRAMMING
When a user clicks a button, scrolls, or simply moves the mouse within a web page, that action creates an event. An event is the browser’s way of signaling that an action happened in the DOM. Events allow us to create interactive web applications that respond to the user’s actions. We do this by writing handlers for specific events: functions that are called when an event occurs. Using event handlers, we can change the color of an element when the user clicks it, move an element around the screen when the user presses a certain key, and much more.
In this chapter you’ll learn how to write event handlers to respond ...
Get JavaScript Crash Course now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.