Once an event is fired, the function it triggers doesn't inherently know how it was triggered. The type event property can tell you what event type was fired, allowing you to write a function that can respond differently depending on how the action was initiated (Figure 15.1). Figure 15.1. The general syntax for detecting the event type
In this example (Figure 15.2), clicking anywhere outside of the image will trigger the click event, but clicking the image will detect the mousedown event. Figure 15.2. The event type that triggered the function (in this case, mousedown) is displayed in the alert message.To find which event type fired:
Tip
|