Chapter 7Events in JavaScript


While HTML is the bedrock of all web pages, it is very static. HTML cannot respond to user input and it provides a limited set of features. When browsing an HTML-based web page you can read the text, look at the graphics, and possibly listen to the sound it plays. All of these actions are static in that the user has no control over the actions the web page takes. Such pages remind us of art masterpieces seen in a museum. You can look at them, maybe take a picture, but you cannot interact with the paintings. We use JavaScript to produce dynamic, interactive content in our HTML web pages. One of the best way to do this is to use events.

Events are actions that occur in response to a specific user action on the ...

Get Advanced Javascript, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.