DOM Javascript Flashcards
What is the purpose of events and event handling?
events check for events that happen and event handling fires it
What do [] square brackets mean in function and method syntax documentation?
optional arguments
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 that gets put into another function as argument and runs
What object is passed into an event listener callback when the event fires?
event object which has properties that tell us it’s current status or data
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
event.target is the target element
Which “document” is being referred to in the phrase Document Object Model?
HTML document and elements
Give two examples of document methods that retrieve a single element from the DOM.
querySelector and getElementByID
Give one example of a document method that retrieves multiple elements from the DOM at once.
querySelectorAll
Why might you want to assign the return value of a DOM query to a variable?
so that we can reuse it later
What console method allows you to inspect the properties of a DOM element object?
console.dir
What does document.querySelector() take as its argument and what does it return?
css selector in string notation
What is the className property of element objects?
it returns name of class
How do you update the CSS class attribute of an element using JavaScript?
use .className
What is the textContent property of element objects?
it returns the content of text