O'Reilly logo

JavaScript Quick Syntax Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 11

image

Events

Events are occurrences that take place in the interaction between the user, the web page, and the browser. Event handling enables a script to detect and react to these occurrences, allowing the web page to become interactive.

Event Handling

There are three steps to handling an event. First, you need to locate the element that will receive the event. Events always take place in the context of element nodes inside the DOM tree. In this example the event will occur when the following hyperlink is clicked.

<a href="http://www.google.com" id="mylink">My link</a>

The next step is to create an event handler, which is the code that will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required