dom-querying Flashcards
Why do we log things to the console?
To debug and see if a certain input is giving the desired output.
What is a “model”?
A mirror or a replica of a thing or the (the DOM tree)
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?
An object of nodes with methods and properties
What is a DOM Tree?
Relationships between the document and all of
the element nodes are described using the same
terms as a family tree.
Give two examples of document methods that retrieve a single element from the DOM.
QuerySelectorAll, and getElementById
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?
For reusability and efficiency, so that a reference of the particular element is stored and every time you need it, you don’t always have to go through the same process of searching for it.
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?
So as to load the content of the HTML first before loading the JavaScript file.
What does document.querySelector() take as its argument and what does it return?
A CSS selector rule and returns the first element to match it.
What does document.querySelectorAll() take as its argument and what does it return?
A CSS selector rule and returns all the elements that match it.