Events in JavaScript

Click on a paragraph. An alert box will alert the element whose eventlistener triggered the event. Try clicking the bold word. Or somewhere else in the paragraph. Notice how the events cascade.

Note: The currentTarget property does not necessarily return the element that was clicked on, but the element whose eventlistener triggered the event.

 

Clicking is not the only even you can capture.

Try dragging the mouse over me.

During normal program execution, a large number of events occur, so the event object is a fairly active object, constantly changing its properties.
Whenever an event fires, the computer places appropriate data about the event into the event object - for example, where the mouse pointer was on the screen at the time of the event, which mouse buttons were being pressed at the time of the event, and other useful information.
Skilled use of the event object can be very rewarding. It opens up possibilities for creating very intricate and complex programs.
The Event model is implemented differently in IE and Firefox. In IE, there is an explicit window.event object that logs any details of an event (ie: onclick) when it occurs, while in Firefox and other W3c compliant browsers, an inexplicit Event object is automatically passed into the function associated with the event handler that contains similar info about the event.