JavaScript Events Worksheet

Questions

Question 1

What is an 'event handler'?

event handlers are functions that are used when an event occurs

Question 2

How are event handlers invoked?

the browser invokes event handlers when a event occurs

Question 3

What is an 'anonymous' function?

when event handler functions do not have names

Question 4

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

It is a method within every object designed for hooking up event handlers. First parameter is a string which is the name of the event being listened for, the second parameter is a function, that is the EH that will be invoked when an event is detected.

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