example, we can use the onClick event of a button element to indicate that a function will run
when a user clicks on the button. We define the events in the HTML elements.
Examples of events:
Note: Events are normally used in combination with functions, and the function will not be
executed before the event occurs
The onload and onUnload events are triggered when the user enters or leaves a page.
The onload event is often used to check the visitor's browser type and version, and load the
proper version of the web page based on that information.
Both the onload and onUnload events are also often used to deal with cookies that should be set
when a user enters or leaves a page. For example, you could have a popup asking for the user's
name upon his first arrival to your page. The name is then stored in a cookie. Next time the
visitor arrives at your page, you could have another popup saying something like: "Welcome
The onFocus, onBlur and onChange events are often used in combination with validation of form
Below is an example of how to use an onChange event. The checkEmail() function will be called
whenever the user changes Content of the e-mail field:
For a complete description and examples of each event, see our HTML DOM Event reference.
Your Query was successfully sent!