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, quietly and methodically moving from the first statement to the last. You’ve seen a few event handlers in use in sample scripts used 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—onclick really does mean “when a click happens.” That alone speaks to the relative ease and simplicity ...

Get HTML, CSS and JavaScript All in One, Sams Teach Yourself: Covering HTML5, CSS3, and jQuery, 2nd Edition 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.