Chapter 19. Responding to Events

WHAT YOU’LL LEARN IN THIS CHAPTER:

• How event handlers work

• How event handlers relate to objects

• How to create an event handler

• How to detect mouse and keyboard actions

• How to use onclick to change the appearance of <div>

In your experience with JavaScript so far, most of the scripts you’ve written have executed in a calm, orderly fashion, moving from the first statement to the last. You’ve seen a few event handlers used in sample scripts to focus your attention on other aspects of programming, and it is likely that you used your common sense to follow along with the actions. That alone speaks to the relative ease and simplicity of using JavaScript event handlers within your HTML.

In this chapter, ...

Get Sams Teach Yourself HTML, CSS and JavaScript All in One 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.