Java Reference
In-Depth Information
The Event Object
Every time an event occurs, the callback function is called. This function is automatically
passed an event object as a parameter that contains information about the event.
To see an example of this, change the doSomething() function in the scripts.js file to
function doSomething(event){
Now refresh the events.htm page in the browser and try clicking again. You should see the
following appear in the console every time you click:
In the example, the event.type property is used to tell us that the type of event that was
logged was a click event.
Note: What's in a Name?
The parameter does not have to be called event . It can be given any legal
variable name, although calling it event can make it easier to read the code.
Many developers often abbreviate it to just e .
Types of Event
The event.type property returns the type of event that occurred, such as click in the
previous example. The different types of events will be discussed in the next section.
Search WWH ::

Custom Search