DOM EVENTS Flashcards
What is the purpose of events and event handling?
Once an event occurs a callback occurs of the event handling
The action follows the event
Are all possible parameters required to use a JavaScript method or function?
No, event listener
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener
What is a callback function?
function being passed to another function
Ex - callback funcion occurs when event takes place
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?
Event target gives the property of which object the event will occur too
console.log
What is the difference between these two snippets of code?
element.addEventListener(‘click’, handleClick)
element.addEventListener(‘click’, handleClick())
2nd gets callled immediately and is replaced by its return value