JavaScript Events Worksheet

Questions

Question 1

What is an 'event handler'?

An event handler is a function that runs in response to a specific event, like a click or mouseover, happening on a page element.

Question 2

How are event handlers invoked?

Event handlers are invoked automatically by the browser when their event happens, such as when the user clicks a button or moves the mouse over an element.

Question 3

What is an 'anonymous' function?

An anonymous function is a function that does not have a name and is usually written directly where it is needed

Question 4

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

addEventListener() is a method on a DOM element that lets you listen for events; the first parameter is the event name, and the second parameter is the function that should run when that event happens.

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