The DOM Events
The following table lists all dom events:
Name | Description |
---|---|
blur | Triggered when the element loses the focus. |
click | Triggered when the mouse button is pressed and released. |
dblclick | Triggered when the mouse button is pressed and released twice. |
focus | Triggered when the element gains the focus. |
focusin | Triggered when the element is just about to gain the focus. |
focusout | Triggered when the element is just about to lose the focus. |
keydown | Triggered when the user presses a key. |
keypress | Triggered when a user presses and releases a key. |
keyup | Triggered when the use releases a key. |
mousedown | Triggered when the mouse button is pressed. |
mouseenter | Triggered when the pointer is moved to be within the screen region occupied by the element or one of its descendants. |
mouseleave | Triggered when the pointer is moved to be outside the screen region occupied by the element and all its descendants. |
mousemove | Triggered when the pointer is moved while over the element. |
mouseout | The same as for mouseleave, except that this event will trigger while the pointer is still over a descendant element. |
mouseover | The same as for mouseenter, except that this event will trigger while the pointer is still over a descendant element. |
mouseup | Triggered when the mouse button is released. |
onabort | Triggered when the loading of a document or resource is aborted. |
onafterprint | Triggered when the Window.print() method is called, before the user is presented with the print options. |
onbeforeprint | Triggered after the user has printed the document. |
onerror | Triggered when there is an error loading a document or resource. |
onhashchange | Triggered when the has fragment changes. |
onload | Triggered when the loading of a document or resource is complete. |
onpopstate | Triggered to provide a state object associated with the browser history. |
onresize | Triggered when the window is resized. |
onunload | Triggered when the document is unloaded from the window/browser. |
readystatechange | Triggered when the value of the readyState property changes. |
reset | Triggered when a form is reset. |
submit | Triggered when a form is submitted. |
The members of the Event object are described in the following table.
Name | Description | Returns |
---|---|---|
type | The name of the event (e.g., mouseover). | string |
target | The element at which the event is targeted. | HTMLElement |
currentTarget | The element whose event listeners are currently being invoked. | HTMLElement |
eventPhase | The phase in the event life cycle. | number |
bubbles | Returns true if the event will bubble through the document, false otherwise. | boolean |
cancelable | Returns true if the event has a default action that can be cancelled, false otherwise. | boolean |
timeStamp | The time at which the event was created, or 0 if the time isn't available. | string |
stopPropagation() | Halts the flow of the event through the element tree after the event listeners for the current element have been triggered. | void |
stopImmediatePropagation() | Immediately halts the flow of the event through the element tree; untriggered event listeners for the current element will be ignored. | void |
preventDefault() | Prevents the browser from performing the default action associated with the event. | void |
defaultPrevented | Returns true if preventDefault() has been called. | boolean |