Skip to main content
InterviewHubPRO
Section Overview
Q105

Question 105 of 536

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

20%
JavaScript & V8 Internals (536 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

What are events

junior LevelCode ExampleHTTP & REST APIs

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
  <!doctype html>
  <html>
   <head>
     <script>
       function greeting() {
         alert('Hello! Good morning');
       }
     </script>
   </head>
   <body>
     <button type="button" onclick="greeting()">Click me</button>
   </body>
  </html>