Chapter 10: Event Handling

10.1 What is an Event?

An event is any interaction that a user makes with the web page. These interactions including clicking a button, resizing a window, loading a page etc. We can write Javascript code to handle these events.

Some of the commonly used events in Javascript include:

Javascript onclick eventonclick
Occurs when the user clicks on an HTML element

onmouseover
Occurs when the user moves the pointing device (e.g. a mouse) onto an element

onmouseout
Occurs when the user moves the pointing device out of an element

onfocus
Occurs when an element receives focus (this happens when we click on the element or use the tab key on our keyboards to move the focus to that element)

onblur
Occurs when an element loses focus

For a complete list of all the events available in Javascript, you can check out the following Wikipedia page:

https://en.wikipedia.org/wiki/DOM_events