DOM Flashcards
Why do we log things to the console?
To check if the output is what we expected
What is a “model”?
A recreation of the original.
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?
The Javascript object.
What is a DOM Tree?
Dom node plus all of the elements that make it up.
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.
querySelectorAll()
Why might you want to assign the return value of a DOM query to a variable?
To reuse the result.
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 that the contents can load top to bottom first.
What does document.querySelector() take as its argument and what does it return?
A string of CSS Selector and takes the first element that matches in the document.
What does document.querySelectorAll() take as its argument and what does it return?
String of CSS Selector and returns all elements that match the selector in the node list.
Why do we log things to the console?
To check our output
What is the purpose of events and event handling?
To add user functionality to the webpage.
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 function passed into another function as an argument.