DOM Flashcards
Why do we log things to the console?
To make sure the code is running correctly and see the data
What is a “model”?
A small representation of something we’re going to build generally
Which “document” is being referred to in the phrase Document Object Model?
The entire HTML document
What is a DOM Tree?
Its a collection of objects that makes up the document
Give two examples of document methods that retrieve a single element from the DOM.
getElementById and querySelector()
Give one example of a document method that retrieves multiple elements from the DOM at once.
Document.querySelectorAll()
Why might you want to assign the return value of a DOM query to a variable?
In case you need to use the same elements more than once
What console method allows you to inspect the properties of a DOM element object?
Console.dir
Why would a
tag need to be placed at the bottom of the HTML content instead of at the top?
Because we need to load HTML first. or else it will run before the HTML, which we wont be able to query the DOM.
What does document.querySelector() take as its argument and what does it return?
selector. It will return the first element in the dom that matches it.
What does document.querySelectorAll() take as its argument and what does it return?
Selector. Returns a node list or a collection of all the elements that match that selector.
What is the word “object” referring to in the phrase Document Object Model?
The document object. we can check it on console.dir()
What is the purpose of events and event handling?
Have some type of response to when a user interacts with the web page
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?
A callback function is a function passed into another function as an argument
What object is passed into an event listener callback when the event fires?
Event object
What is the event.target?
Target its what the user interacted with. For example, the button ‘Click Me’
It targets the element that triggered the event.