Affiliate link

HTML - Events

HTML events are fired arise from user interactions such as mouse click, drag, form submission, resize windows. JavaScript function will be triggered from HTML events.

The HTML events are listed below,

HTML - Window Events attributes

Event attributesDescriptionEvent type
onafterprintAfter the HTML document has started printing or the print preview dialog box has been closed.Event
onbeforeprintWhen the HTML document is previewed for printing.Event
onbeforeunloadBefore the HTML document unloaded.BeforeUnloadEvent
onerrorWhen the HTML document failed to load.Event/UIEvent
onhashchangeWhen the #hash URL has changed.HashChangeEvent
onloadWhen the HTML document is loaded with all resources.Event
onmessageWhen the window receives a message.MessageEvent
onmessageerrorWhen the window receives a message that cannot be deserialized.MessageEvent
onofflineWhen the network status is offline.Event
ononlineWhen the network status is online.Event
onpagehideWhen user go to other URL.PageTransitionEvent
onpageshowWhen user go to page URL.PageTransitionEvent
onpopstateWhen the active history entry of the browser changes.PopStateEvent
onresizeWhen the window is resized.UIEvent
onstorageWhen a storage(localStorage) has been modified.StorageEvent
onunloadWhen the HTML document is unloaded.Event

HTML - Form Events attributes

Event attributesDescriptionEvent type
onblurWhen element lost focus.
onchangeWhen the value of the element changed.
oncontextmenuWhen a context menu is displayed.
onfocusWhen an element get focused.
oninputWhen an element get input from user.
oninvalidWhen an element is invalid.
onresetWhen the form get reset.
onsearchWhen the search input get input from user.
onselectWhen the text of an element selected.
onsubmitWhen the form is going to be submitted.
Affiliate link

HTML - Keyboard Events attributes

Event attributesDescriptionEvent type
onkeydownWhen user press a key.
onkeypressWhen user pressed a key.
onkeyupWhen user released a key.

HTML - Mouse Events attributes

Event attributesDescriptionEvent type
onclickWhen mouse clicked on an element.
ondblclickWhen mouse double-clicked on an element.
onmousedownWhen mouse is pressed on an element.
onmousemoveWhen mouse is moving on an element.
onmouseoutWhen mouse is moved out of an element.
onmouseoverWhen mouse is moved over an element.
onmouseupWhen mouse is released on an element.
onmousewheelDepreciated. Use onwheel attribute.
onwheelWhen mouse wheel is rolled up/down on an element.

HTML - Drag Events attributes

Event attributesDescriptionEvent type
ondragWhen an element is dragging on mouse pressed.
ondragendWhen an element is dragged on mouse released.
ondragenterWhen the dragged element is dragged to an element.
ondragleaveWhen the dragged element is dragged out of an element.
ondragoverWhen the dragged element is dragged over to an element.
ondragstartWhen the element is getting dragged.
ondropWhen the dragged element is dropped to an element.
onscrollWhen the element's scrollbar is scrolled.

HTML - Clipboard Events attributes

Event attributesDescriptionEvent type
oncopyWhen the user do a copy action on an element.
oncutWhen the user do a cut action on an element.
onpasteWhen the user do a paste action to an element.
Affiliate link

HTML - Media Events attributes

Event attributesDescriptionEvent type
onabortWhen the media resource not fully loaded.
oncanplayWhen the media resource can be played without loading fully.
oncanplaythroughWhen the media resource can be played without stopping for buffer.
oncuechangeWhen currently playing cue changed.
ondurationchangeWhen the duration attribute modified.
onemptiedWhen the media resource become empty due to load() method executed.
onendedWhen the media resource playback ended.
onerrorWhen the media resource unable to load due to an error.
onloadeddataWhen the playback position of the media resource is loaded.
onloadedmetadataWhen the metadata is loaded.
onloadstartWhen media resource start to load.
onpauseWhen pause() method is called and the media element's paused property is changed to true.
onplayWhen the media element's paused property is changed to false.
onplayingWhen playback is started or restarted.
onprogressWhen the media resource is loading.
onratechangeWhen the playback rate is changed.
onseekedWhen seek operation completed, playback position is changed, and seeking attribute changed to false
onseekingWhen seek operation started and seeking attribute is changed to true.
onstalledWhen the media resouce not able to load by user agent.
onsuspendWhen media resouce loading has been suspended.
ontimeupdateWhen the currentTime attribute is updated.
onvolumechangeWhen the volume is changed.
onwaitingWhen playback is stopped because temporary lack of media resource.

HTML - Others Events attributes

Event attributesDescriptionEvent type
ontoggleWhen the state of the element is toggled.
Affiliate link
Affiliate link
Advertisment
StudioPress
Get Surfshark VPN