DOM Flashcards
Why do we log things to the console?
so we can check our code for bugs along the way and make sure everything is running without error
What is a “model”?
something you want to mirror or follow
Give two examples of document methods that retrieve a single element from the DOM.
getElementbyId & querySelector
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 you can store the reference or location of the element you’re trying to retrieve into the variable so the browser doesn’t have to keep going back to look for the element
What console method allows you to inspect the properties of a DOM element object?
console.dir
Which “document” is being referred to in the phrase Document Object Model?
the HTML document
What is the word “object” referring to in the phrase Document Object Model?
javascript objects
What is a DOM Tree?
A model of the page when it loads in a browser in the form of a tree.
Why would a <a>«/a>script<a>></a> tag need to be placed at the bottom of the HTML content instead of at the top?</a>
the content of the HTML page need to be set first before the dom tree is made
What does document.querySelector() take as its argument and what does it return?
takes in a css selector and returns the first element that matches
What does document.querySelectorAll() take as its argument and what does it return?
takes in a css selector and returns a NodeList
What is the purpose of events and event handling?
add dynamic content and interactivity. respond to occurrences.
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
What is a callback function?
function definition being passed around as a value so it can be invoked later
What object is passed into an event listener callback when the event fires?
event.object
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
place where the event actually occurred.