DOM Flashcards
Why do we log things to the console?
to know what the code is doing
What is a “model”?
representation of something;
Which “document” is being referred to in the phrase Document Object Model?
the entire page
What is the word “object” referring to in the phrase Document Object Model?
data types, collection of data
What is a DOM Tree?
all the nodes of the elements
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.
.getElementsByClassName()
Why might you want to assign the return value of a DOM query to a variable?
so the location of the value is saved and JS doesn’t have to find it again
What console method allows you to inspect the properties of a DOM element object?
.dir()
Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?
HTML needs to load first because JS needs to know what to work with
What does document.querySelector() take as its argument and what does it return?
takes in a CSS selector,
returns the first match of the selector
What does document.querySelectorAll() take as its argument and what does it return?
takes in a CSS selector, returns the all the matches of the selector in a node list
What is the purpose of events and event handling?
user interaction
What do [] square brackets mean in function and method syntax documentation?
they’re optional
What is a callback function?
a function passed into another function as an argument