Event Object
Event Object
All event objects in the DOM are based on the Event object.
Therefore, all other event objects (such as MouseEvent and KeyboardEventAll of the above can access the properties and methods of the Event object.
Event properties and methods
Property/Method | Description |
---|---|
bubbles | Returns whether a specific event is a bubbling event. |
cancelBubble | Sets or returns whether the event should propagate up the hierarchy. |
cancelable | Returns whether the event can prevent its default action. |
composed | Indicates whether the event can be passed from the Shadow DOM to the general DOM. |
composedPath() | Returns the path of the event. |
createEvent() | Creates a new event. |
currentTarget | Returns the element that triggered the event's listeners. |
defaultPrevented | Returns whether preventDefault() was called for the event. |
eventPhase | Returns which phase of the event flow the current event assessment is in. |
isTrusted | Returns whether the event is trusted. |
preventDefault() | If the event can be canceled, it is canceled without executing the default action associated with the event. |
stopImmediatePropagation() | Prevents other listeners for the same event from being called. |
stopPropagation() | Prevents the event from further propagating in the event flow. |
target | Returns the element that triggered the event. |
timeStamp | Returns the time the event was created (in milliseconds relative to the epoch). |
type | Returns the event name. |
Event type
These event types belong to the Event object:
Event | Description |
---|---|
abort | This event occurs when the media loading is aborted. |
afterprint | This event occurs when the page starts printing or the print dialog is closed. |
beforeprint | This event occurs when the page is about to be printed. |
beforeunload | This event occurs before the document is unloaded. |
canplay | This event occurs when the browser can start playing the media. |
canplaythrough | This event occurs when the browser can play media without stopping the buffering. |
change | This event occurs when the content of the form element, the selected content, or the selected state changes. |
error | This event occurs after an error occurs while loading an external file. |
fullscreenchange | This event occurs when an element is displayed in full-screen mode. |
fullscreenerror | This event occurs when an element cannot be displayed in full-screen mode. |
input | This event occurs when an element receives user input. |
invalid | This event occurs when an element is invalid. |
load | This event occurs when the object has been loaded. |
loadeddata | This event occurs after the media data is loaded. |
loadedmetadata | This event occurs when metadata (such as size and duration) is loaded. |
message | This event occurs when receiving messages through this event source. |
offline | This event occurs when the browser starts working offline. |
online | This event occurs when the browser starts working online. |
open | This event occurs when a connection to the event source is opened. |
pause | This event occurs when the media is paused by the user or paused programmatically. |
play | This event occurs when the media has started or is no longer paused. |
playing | This event occurs when the media is paused or stopped to buffer and then played back. |
progress | This event occurs when the browser is in the process of obtaining media data. |
ratechange | This event occurs when the playback speed of the media changes. |
resize | This event occurs when the size of the document view is adjusted. |
reset | This event occurs when a form is reset. |
scroll | This event occurs when the scrollbar of a scrolling element is manipulated. |
search | This event occurs when the user types content into the search field. |
seeked | This event occurs when the user finishes moving or jumping to a new position in the media. |
seeking | This event occurs when the user starts moving or jumping to a new position in the media. |
select | This event occurs after the user selects text (for <input> and <textarea>). |
show | This event occurs when the <menu> element is displayed as a context menu. |
stalled | This event occurs when the browser tries to fetch media data but the data is not available. |
submit | This event occurs when a form is submitted. |
suspend | This event occurs when the browser intentionally does not retrieve media data. |
timeupdate | This event occurs when the playback position changes. |
toggle | This event occurs when the user opens or closes the <details> element. |
unload | This event occurs after the page has unloaded (for <body>). |
waiting | This event occurs when the media has paused but is expected to resume. |