Events are "things" that happen to HTML elements. When JavaScript is used in HTML pages, JavaScript can react
on these events. Some of the examples of HTML events are,
- Web page has finished loading
- Input field was changed
- Button was clicked
Let's describe the behavior of click event for button element,
<!doctype html>
<html>
<head>
<script>
function greeting() {
alert('Hello! Good morning');
}
</script>
</head>
<body>
<button type="button" onclick="greeting()">Click me</button>
</body>
</html>