HTML events can be browser or user behavior.
Here are examples of HTML events:
- HTML page finishes loading
- When the HTML input field changes
- HTML button is clicked
Usually, you can do something when an event occurs.
With twofold quotes:
In the accompanying precedent, an onclick trait (with code), is added to a catch element:
Common HTML Events
Here is a rundown of some regular HTML events:
|onchange||HTML element changes|
|onclick||User clicks on HTML element|
|onmouseover||The user moves the mouse over an HTML element|
|onmouseout||The user removes the mouse from an HTML element|
|onkeydown||User presses a keyboard key|
|onload||The browser has finished loading the page|
Events can be used to handle form validation, user input, user behavior, and browser actions:
- Event is triggered when the page loads
- Event is triggered when the page is closed
- The user clicks a button to perform an action
- Verify the legitimacy of user input
- Wait ...
- You can specify your own event handler for HTML elements
- You can prevent the event from happening.
- Wait ...
| You will learn more about events and event handlers in the HTML DOM chapter.