DOM Flashcards
Why do we log things to the console?
To verify that the result is what we’re expecting
What is a “model”?
A representation/recreation of the actual thing. In this case, a DOM tree
Which “document” is being referred to in the phrase Document Object Model?
The HTML/web page
What is the word “object” referring to in the phrase Document Object Model?
JavaScript object
What is a DOM Tree?
Data representation of all the objects in the document. Any of the element and all of its child and content
Give two examples of document methods that retrieve a single element from the DOM.
querySelector(), getElementById()
Give one example of a document method that retrieves multiple elements from the DOM at once.
querySelectorAll(), getElementsByClassName(), getElementsByTagName()
Why might you want to assign the return value of a DOM query to a variable?
If you want to reuse the query
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 parse all of the elements in the HTML page before JavaScript can access them
What does document.querySelector() take as its argument and what does it return?
It will take a CSS selector and returns the first matching element
What does document.querySelectorAll() take as its argument and what does it return?
It will take a CSS selector and returns all matching elements in a node list
Why do we log things to the console?
To verify that the result is what we’re expecting
What is the purpose of events and event handling?
So our script can respond to certain events/user inputs
Are all possible parameters required to use a JavaScript method or function?
No, having a parameter for a function doesn’t mean that it will be used