dom events Flashcards
What is the purpose of events and event handling?
to react to changes on the page and run code based on user input/interaction
Are all possible parameters required to use a JavaScript method or function?
no
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener(‘event’, callbackFunction)
What is a callback function?
a function that is passed as an argument to another function, and called by an event or something else later
What object is passed into an event listener callback when the event fires?
event
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
the element that triggered the event. console.log it!
What is the difference between these two snippets of code?
element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())
the second one is passing a function CALL, not just the function. This callback will run prematurely