DOM Querying Flashcards
Why do we log things to the console?
To check and debug the code we are testing
What is a ‘model’?
An outline or skeleton of something
Which ‘document’ is being referred to in the phrase Document Object Model?
The HTML doc
What is the word ‘object’ referring to in the phrase Document Object Model?
The different parts ‘elements’ of an HTML page
What is a DOM tree?
A model of an HTML page
Give two examples of document methods that retrieve a single element form the DOM.
getElementById() and quertySelector()
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?
To make it easier to access that return value later
What console method allows you to inspect the properties of a DOM element object?
console.dir
Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?
To load in all the elements of the HTML page before using JavaScript to access and change those elements.
What does document.querySelector() take as its argument and what does it return?
It takes in CSS selectors as a DOMString and returns the first element matching the css selector
What does document.querySelectorAll() take as its argument and what does it return?
It takes in CSS selectors as a DOMString and returns a NodeList that contains elements matching the css selector