Events are an integral part of most web pages: they allow you to take an action when something happens. The “something happens” is called an event, and there are dozens of them that have been defined in the web standard (see http://www.w3.org/TR/DOM-Level-3-Events/#events-module ). The “an action” is called an event handler, which is just a simple JavaScript function.
Initial Example
I'll start with a simple example and then describe the pieces. A basic HTML document is shown in Listing 20-1.
Listing 20-1. The initial HTML document
<!DOCTYPE html>
<html lang="en">
<head> ...