CodesCompiler
πŸ”
HTMLCSSJavaScriptPythonSQLPHPSEOPostsBooksKids About Contact πŸš€ Get Started Free

HTML - Events Reference

HTML - Events Reference

When users visit your website, they do things like click various links, bring mouse over text and images etc. These are examples of what we call events in JavaScript and VBScript terminologies.

We can write our event handlers using JavaScript or VBScript and can specify some actions to be taken against these events. Though these are the events but they will be specified as attributes for the HTML tags.

The HTML 4.01 specification had defined 19 events but later HTML-5 has added many other events which we have listed down here βˆ’

Window Events Attributes

Following are the window events attributes that are listed below βˆ’

Sr.NoEvents & Description
1onafterprint Triggers after a document is printed
2onbeforeprint Triggers before a document is printed
3onbeforeunload Triggers before a document loads
4onerror Triggers when an error occurs
5onhashchange Triggers when a document has changed
6onload Triggers when a document loads
7onoffline Triggers when a document goes offline
8ononline Triggers when a document comes online
9onpagehide Triggers when a window is hidden
10onpageshow Triggers when a window becomes visible
11onresize Triggers when a window is resized
12onunload Triggers when a user leaves the document

Form Events

Following are the Form events attributes that are listed below βˆ’

Sr.NoEvents & Description
1onblur Triggers when a window loses focus
2onchange Triggers when an element changes
3oncontextmenu Triggers when a context menu is triggered
4onfocus Triggers when a window gets focus
5oninput Triggers when an element gets user input
6oninvalid Triggers when an element is invalid
7onreset Triggers when a form is reset
8onsearch The HTML onsearch event allows to run specific JavaScript code when a user conducts a search action within a searchable input field.
9onselect Triggers when an element is selected
10onsubmit Triggers when a form is submitted

Keyboard Events

Following are the HTML Keyboard Events that are listed below βˆ’

Sr.NoEvents & Description
1onkeydown Triggers when a key is pressed
2onkeyup Triggers when a key is released

Mouse Events

Following are the Mouse events attributes that are listed below βˆ’

Sr.NoEvents & Description
1onclick Triggers on a mouse click
2ondblclick Triggers on a mouse double-click
3onmousedown Triggers when a mouse button is pressed
4onmousemove Triggers when the mouse pointer moves
5onmouseout Triggers when the mouse pointer moves out of an element
6onmouseover Triggers when the mouse pointer moves over an element
7onmouseup Triggers when a mouse button is released
8onwheel When the mouse wheel is over an element, the HTML onwheel event takes place.

Drag Events

Following are the HTML drag events that are listed below βˆ’

Sr.NoEvents & Description
1ondrag Triggers when an element is dragged
2ondragend Triggers at the end of a drag operation
3ondragenter Triggers when an element has been dragged to a valid drop target
4ondragleave Triggers when an element leaves a valid drop target
5ondragover Triggers when an element is being dragged over a valid drop target
6ondragstart Triggers at the start of a drag operation
7ondrop Triggers when a dragged element is being dropped
8onscroll Triggers when an element’s scrollbar is being scrolled

Clipboard Events

Let’s look into the following clipboard events that are listed below βˆ’

Sr.NoEvents & Description
1oncopy Triggers when an element is copied by the user
2oncut Triggers when an element is removed (cut) by the user
3onpaste Triggers when an element is being pasted into an input field.

Media Events

Following are the Media events attributes that are listed below βˆ’

Sr.NoEvents & Description
1ondurationchange Triggers when the length of a media is changed
2onended Triggers when a media has reached the end
3onerror Triggers when an error occurs
4onloadeddata Triggers when media data is loaded
5onloadedmetadata Triggers when the duration and other media data of a media element is loaded
6onloadstart Triggers when the browser starts loading the media data
7onpause Triggers when media data is paused
8onplay Triggers when media data is going to start playing
9onplaying Triggers when media data has started playing
10onprogress Triggers when the browser is fetching the media data
11onratechange Triggers when the playing rate of media data has changed
12onseeked Triggers when the seeking attribute of a media element is no longer true, and the seeking has ended
13onseeking Triggers when the seeking attribute of a media element is true, and the seeking has begun
14onstalled Triggers when there is an error in fetching media data
15onsuspend Triggers when the browser has been fetching media data, but stopped before the entire media file was fetched
16ontimeupdate Triggers when media changes its playing position
17onvolumechange Triggers when a media changes the volume, also when volume is set to β€œmute”
18onwaiting Triggers when media has stopped playing, but is expected to resume

Misc Events

Following the misc event listed below βˆ’

Sr.NoEvent & Description
1ontoggle In general, the toggle means it toggles between hide() and show() for the selected element.