JavaScript Events Worksheet

Questions

Question 1

What is an 'event handler'?

An event handler is a function that gets invoked when a specified event occurs.

Question 2

How are event handlers invoked?

When the event that they are "listening for" occurs, it is invoked. For example, when someone clicks a button, the handler that is "listening" for a click, will invoke its funtion.

Question 3

What is an 'anonymous' function?

It is a function that doesn't have a name.

Question 4

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

The addEventListener() allows you to attach an event handler to a DOM object.

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