Here is the description of HTML Events:
- HTML events are actions or occurrences that happen in the browser, such as a user clicking a button, moving the mouse, pressing a key, or the page finishing loading.
- In HTML, events can be used to trigger JavaScript code, allowing developers to create interactive and dynamic web pages. Here are some commonly used HTML events:
Mouse Events:
onclick
:- Fires when an element is clicked.
onmouseover
and onmouseout
:
- Triggered when the mouse pointer enters or leaves an element.
onmousedown
, onmouseup
, and onmousemove
:
- Fired when a mouse button is pressed, released, or moved over an element.
Keyboard Events:
onkeydown
,onkeyup
, andonkeypress
:- Triggered when a key is pressed down, released, or pressed (respectively).
Form Events:
onsubmit
:- Fired when a form is submitted.
onchange
:
- Triggered when the value of an input element changes.
Window Events:
onload
andonunload
:- Fired when the page finishes loading or unloading.
onresize
:
- Triggered when the browser window is resized.
Event Attributes:
onfocus
andonblur
:- Fired when an element gains or loses focus.
onchange
:
- Triggered when the content of an element, such as an input field, changes.
Custom Events:
- You can also define and trigger custom events in JavaScript using the
CustomEvent
constructor.