Event
In programming, an event is an action that occurs as a result of the user or another source, such as a mouse being clicked or a key being pressed. An event handler is a routine that is used to handle the event, allowing a programmer to write code that will be executed when the event occurs.
For example, a user might click on a button within a web page. This would create a "click" event on the button. In JavaScript to program the reaction to the event, you could use the onclick event handler to create a reaction to the event, as shown below.
<form action="#" method="post">
<input type="button" value="Click for a Message" onclick="window.alert('Hello!');">
</form>
This reacts to a click event on the button, sending the "Hello" message the viewer. To see this in action, be sure JavaScript is enabled in your browser and click the example button below to get the message.
Also see: Programming definitions
