JavaScript Events Worksheet

Questions

Question 1

What is an 'event handler'?

Handles or manages events such as user input, interaction, or things like page load.

Question 2

How are event handlers invoked?

By listening for events such as click or mouse over and executing a function.

Question 3

What is an 'anonymous' function?

A function that is without a name usually incorporated, in this case, within an event listener as an argument.

Question 4

Explain what the addEventListener() method of a DOM element is, and explain the purpose of each of it's parameters.

This method (function) is waiting until the event (interaction) is triggered which is listed as the first parameter, ex. "click". The second parameter is the function or what happens when that event is triggered.

Coding Problems

Coding Problems - See the 'script' tag below this h3 tag. You will have to write some JavaScript code in it.

Always test your work! Check the console log to make sure there are no errors.

Orange

Green