DOM Querying Flashcards
Why do we log things to the console?
To see our code and help debug
What is a “model”?
A Data Structure
Which “document” is being referred to in the phrase Document Object Model?
Document Node (all of our html).
What is the word “object” referring to in the phrase Document Object Model?
Model made of objects
What is a DOM Tree?
Model of the HTML
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.
querySelectorAll( ), getElementsByClassName( )
Why might you want to assign the return value of a DOM query to a variable?
For multiple use and efficiency
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?
It gives the HTML time to load before any of the JavaScript loads, which can prevent errors, and speed up website response time.
What does document.querySelector() take as its argument and what does it return?
a CSS selector, and returns the first matching element.
What does document.querySelectorAll() take as its argument and what does it return?
a CSS selector, and returns all matching element.