DOM Flashcards
Why do we log things to the console?
For debugging and an easy way to inspect your variables in the browser
What is a “model”?
Replica
Which “document” is being referred to in the phrase Document Object Model?
The HTML
What is the word “object” referring to in the phrase Document Object Model?
JavaScript object
What is a DOM Tree?
DOM element and all of the items in it
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?
For reusability and accessibility
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?
The browser needs to run the html document first in order to create a DOM
What does document.querySelector() take as its argument and what does it return?
CSS selector and it returns the first element from the document
What does document.querySelectorAll() take as its argument and what does it return?
CSS selector and it returns NodeList of all elements matching the selector
What is the purpose of events and event handling?
Events are actions or occurrences that happen in the system
Event handling is steps to trigger some JavaScript code
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