W3C DOM Events
| type | event description | target |
|---|---|---|
| load | Fires when HTML and all resources of a web page have finished loading | document, window |
| unload | Fires when web page is unloading for a new page requested | body, window |
| error | Fires when browser encounter a JS error or resource does not exist (inconsistent support) | |
| resize | Fires repeatedly as browser's window is being resized | window |
| scroll | Fires repeatedly as user scrolls web page | document, element |
|
Usage:
|
||
| type | event description |
|---|---|
| focus or focusin | Element gains focus |
| blur or focusout | Element loses focus |
|
Usage:
|
|
| type | event description |
|---|---|
| click |
|
| dblclick |
|
| mousedown | User presses a mouse button over an element (like touchstart on touchscreen) |
| mouseup | User releases a mouse button over an element (like touchend on touchscreen) |
| mouseover | User moves the mouse over an element. (not on touchscreen) |
| mousemove | Fire repeatedly when user moves the mouse around an element. (not on touchscreen) |
| mouseout | User moves the mouse off an element (not on touchscreen) |
|
Usage:
|
|
| type | event description |
|---|---|
| input |
Fires when the content of <input> or <textarea> change. Incomplete support in IE9. For older browser you should use the keydown event |
| keydown |
Fire when user presses a key on the keyboard. Fire repeatedly while the user hold down the key |
| keyup | Fire when user releases a key |
| keypress | Fire when user presses a key of a printable character |
|
Usage:
|
|
| type | event description |
|---|---|
| DOMNodeInserted | |
| DOMNodeRemoved | |
| DOMSubtreeModified | |
| DOMNodeInsertedIntoDocument | |
| DOMNodeRemovedFromDocument | |
|
Usage:
|
|
W3C HTML5 Events
| event type | event description |
|---|---|
| input | Fires when value in <input> or <textarea> or element with contenteditable attribute has changed (IE9+) |
| change | Fires when user makes a change in the value of select box, checkbox or radio button ha changed (IE9+) |
| submit | Fire on the node representing the <form> element, when the form is submitted. |
| reset | User clicks on reset button |
| cut | User cuts content from a form field |
| copy | User copies content from a form field |
| paste | User pastes content into a form field |
| select | User selects text in a form field |
|
Usage:
|
|
| type | event description | target |
|---|---|---|
| DOMContentLoaded | Event fires when the DOM tree is formed, but linked resources (CSS, JS, images) are still being loaded. (IE9+) | document, window |
| readystatechange | Fires fires when document's readyState property is changed. (Can be used as an alternative to the DOMContentLoaded for olderIE) | document, XMLHTTPRequest |
| hashchange | Event fires when the URL hash changes. URL's hashs AKA anchors link parts of a document within a page. (IE8+) | window |
| beforeunload | Event fires before the page is unloaded. It shows a dialog box to the user. | window |
Example: (HTML5 FormEvent) input event
See the Pen input event with textarea by Massimiliano De Simone (@maxdesimone) on CodePen.
Example: (DOM4 FocusEvent) blur and (HTML5 FormEvents) change events
See the Pen JS events: Form and Focus Event Interfaces by Massimiliano De Simone (@maxdesimone) on CodePen.
Example: (DOM2 MouseEvent) mouseover, mouseout and mousemove events
See the Pen JS events: three mouse events by Massimiliano De Simone (@maxdesimone) on CodePen.
No comments:
Post a Comment