From the course: JavaScript Essential Training

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

DOM events explained

DOM events explained

- This headlamp has hidden features. In addition to just turning it on and off with the button, I can also change the brightness of the light by turning it on and then holding down the button. I can also change the type of light emitted if I rapid click the button. And when I click the button, it indicates how much battery is left on it. This is all possible thanks to event handling. Anytime a defined event happens, like the button being pressed and released, the program inside the flashlight detects that event, identifies what type of event it was and fires the corresponding program. So pressing and releasing the button is one event. It turns the light on and off. Another event is pressing and holding the button. It triggers the brightness level to change. Yet another event is pressing and releasing rapidly. It triggers mode changes. When we interact with computer software, we are literally firing events that are then…

Contents