What are Events?
Events are actions or occurrences that happen in the system you are programming, which the system tells you about so you can respond to them in some way if desired. For example if the user clicks a button on a webpage, you might want to respond to that action by displaying an information box.
HTML events are “things” that happen to HTML elements.
An HTML event can be something the browser does, or something a user does.
Here are some examples of HTML events:
- An HTML web page has finished loading
- An HTML input field was changed
- An HTML button was clicked
Often, when events happen, you may want to do something.
Common HTML Events
Here is a list of some common HTML events:
|onchange||An HTML element has been changed|
|onclick||The user clicks an HTML element|
|onmouseover||The user moves the mouse over an HTML element|
|onmouseout||The user moves the mouse away from an HTML element|
|onkeydown||The user pushes a keyboard key|
|onload||The browser has finished loading the page|
What is Event handler?
Event handlers can be used to handle, and verify, user input, user actions, and browser actions.
- Things that should be done every time a page loads
- Things that should be done when the page is closed
- Action that should be performed when a user clicks a button
- Content that should be verified when a user inputs data
- And more …
- You can assign your own event handler functions to HTML elements.
- You can prevent events from being sent or being handled.