DOM Flashcards
What is a “model”?
a tree
Which “document” is being referred to in the phrase Document Object Model?
html file
What is the word “object” referring to in the phrase Document Object Model?
data type objects
What is a DOM Tree?
model structure
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()
Why might you want to assign the return value of a DOM query to a variable?
for reusability and so you can access other information within the DOM object
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 when the user first load the page, all content can get loaded up first before DOM
What does document.querySelector() take as its argument and what does it return?
string of css selector, return first matched item
What does document.querySelectorAll() take as its argument and what does it return?
string of css selector, return nodeList of all the matched items
What is the purpose of events and event handling?
prepare of incoming actions and response with something (interactive)
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?
function that is passed into another function (not calling it)
What object is passed into an event listener callback when the event fires?
event data