The click event fires when the user clicks on an element OR activates an element by other means (i.e. the keyboard). It is the most important JavaScript event. The other events on this page are strictly subsidiary.
“click” event is really a misnomer: it should be called the “activate” event. (And the Microsoft activate event is in fact not a click event but a focus event. You’re still with me?)
Don't register click and dblclick events on the same element: it's impossible to distinguish single-click events from click events that lead to a dblclick event.
| Event | IE 5.5 | IE 6 | IE 7 | IE8rc1 as IE7 | IE8rc1 as IE8 | FF 2.0 | FF 3.0 | FF 3.1b2 | Saf 3.0 Win | Saf 3.1 Win | iPhone 3G | Chrome 1.0 | Opera 9.62 | Opera 10a | Konqueror 3.5.7 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
On the window
|
No | Yes | Yes | Yes | Minimal | Incom |
|||||||||
|
Are these events available on the window?
|
|||||||||||||||
|
On the document
|
Yes | Yes | Yes | Yes | Yes | Yes | |||||||||
|
Are these events available on the document? |
|||||||||||||||
|
On form fields and links
|
Yes | Yes | Incom |
Yes | Yes | Yes | Incom |
||||||||
|
Are these events available on form fields and links?
|
|||||||||||||||
|
On labels
A mousedown, mouseup and click event fire on the label, and then a click event fires on the related form field. |
Yes | Yes | Yes | Yes | Incor |
Too many | |||||||||
|
|||||||||||||||
|
On any element
|
Yes | Yes | Yes | Yes | Yes | Yes | |||||||||
|
Are these events available on any element? |
|||||||||||||||
|
Click as activate
|
Yes | Yes | Yes | Untest |
Yes | Almost | Yes | Too many | |||||||
|
A click event should also fire when the user activates an element (such as a link, checkbox or button) through the keyboard. IE, Firefox and Opera allows users to check radios in the same group by using the arrow keys and the space bar once they've tabbed to one of the radios. In that case the click event fires, too, except in Opera 9.26.
|
|||||||||||||||
| Event | IE 5.5 | IE 6 | IE 7 | IE8rc1 as IE7 | IE8rc1 as IE8 | FF 2.0 | FF 3.0 | FF 3.1b2 | Saf 3.0 Win | Saf 3.1 Win | iPhone 3G | Chrome 1.0 | Opera 9.62 | Opera 10a | Konqueror 3.5.7 |
|
dblclick
|
Yes | Yes | Yes | No | Yes | Yes | No | ||||||||
|
Is the dblclick event supported? |
|||||||||||||||
|
Events leading to dblclick
|
Incom |
Yes | Yes | Untest |
Yes | Yes | Untest |
||||||||
|
IE uses the following event order:
|
|||||||||||||||
|
Bubbling
|
Yes | Yes | Yes | Yes | Almost | Almost | |||||||||
|
These events should bubble up.
|
|||||||||||||||
|
Cancel bubble
|
Yes | Yes | Yes | Yes | Yes | Yes | |||||||||
|
These events should bubble up.
|
|||||||||||||||
|
Prevent default
|
Almost | Almost | Almost | Almost | Almost | Almost | |||||||||
|
All click default actions should be cancelable. That's one of the points of this important event.
|
|||||||||||||||
| Event | IE 5.5 | IE 6 | IE 7 | IE8rc1 as IE7 | IE8rc1 as IE8 | FF 2.0 | FF 3.0 | FF 3.1b2 | Saf 3.0 Win | Saf 3.1 Win | iPhone 3G | Chrome 1.0 | Opera 9.62 | Opera 10a | Konqueror 3.5.7 |
The iPhone fires the mousedown, mouseup and click events in the correct order on a click (tap), but it either fires all three or none at all. Holding your finger down on an element and waiting for it to lose focus after a while does not fire any events, even though a case could be made for firing the mousedown event as soon as the user’s finger touches the screen.
A double-tap has a special meaning on the iPhone (zoom in/out), so it’s understandable that the dblclick event is not supported.
| Event | IE 5.5 | IE 6 | IE 7 | IE8rc1 as IE7 | IE8rc1 as IE8 | FF 2.0 | FF 3.0 | FF 3.1b2 | Saf 3.0 Win | Saf 3.1 Win | iPhone 3G | Chrome 1.0 | Opera 9.62 | Opera 10a | Konqueror 3.5.7 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
DOMActivate
Should fire when an element is activated. |
No | Yes | Incor |
No | Incor |
||||||||||
|
A link is activated when the user follows it. A checkbox or radio is activated when it is checked or unchecked.
|
|||||||||||||||
| Event | IE 5.5 | IE 6 | IE 7 | IE8rc1 as IE7 | IE8rc1 as IE8 | FF 2.0 | FF 3.0 | FF 3.1b2 | Saf 3.0 Win | Saf 3.1 Win | iPhone 3G | Chrome 1.0 | Opera 9.62 | Opera 10a | Konqueror 3.5.7 |