Title:
JavaScript Events Worksheet
Updated:
November 16, 2023
Task/Activity:
  1. Questions
  2. Coding Problems
A. Questions
  1. What is an 'event handler'?
An event handler is a piece of code that listens for the browser to tell it that something is happening, and then responds to that something.
  1. How are event handlers invoked?
By an event occuring. Unless you are talking about the form for it, which is x.addEentListener('event', function);
  1. What is an 'anonymous' function?
A function that is used without defining it, or giving it something to be called by. i.e. I could define a function "function", and call it, or I could use the function in the middle of something, essentially defining the body of the function as it is being used.
  1. Explain what the addEventListener() method of a DOM element is, and explain the purpose of each of it's parameters.
the addEventListener() method is a means by which you can detect if something is happening to some particular DOM element, such as being clicked or loaded or what have you. The parameters: event, which is the event being listened for. function, which is what will happen upon the event happening. Finally, there is a rarely used third parameter that takes a boolean value, that determines whether the listener listens for the event outside of the specific element.
B. 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