Advertisement
728x90
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,
1. Web page has finished loading
2. Input field was changed
3. Button was clicked
Let's describe the behavior of click event for button element,
javascript
1<!doctype html>
2 <html>
3 <head>
4 <script>
5 function greeting() {
6 alert('Hello! Good morning');
7 }
8 </script>
9 </head>
10 <body>
11 <button type="button" onclick="greeting()">Click me</button>
12 </body>
13 </html>Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 16
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
101of476