Account
Categories

Events and Their Types


Definition:

An event is an action a user performs on a webpage. For example, when someone opens a website like www.edutation.com, moves the mouse over a JavaScript topic, or clicks on something, these actions are called events.

When the page reacts to these actions, it is called the event response.

In short, opening a page, moving the mouse over something, or clicking are all examples of events.

Some common event types in JavaScript include:

onclick
onmouseover
onmouseout
onchange
onkeypress
  

Now you will clearly understand with the help of the flowchart.

Start
  |
  v
User performs an action (click, type, move mouse)
  |
  v
Browser detects the event
  |
  v
Is there an event handler?
  |
  |-- Yes --> Run the assigned JavaScript function
  |             |
  |             v
  |        Page responds to the event
  |             |
  |             v
  |            End
  |
  |-- No --> Nothing happens
                |
                v
               End