dom Flashcards
Why do we log things to the console?
access of value
What is a “model”?
representation of a structure
Which “document” is being referred to in the phrase Document Object Model?
HTML document
What is the word “object” referring to in the phrase Document Object Model?
js object; a object that is modeling the object document
What is a DOM Tree?
object model; model made of objects; stored in browser’s memory
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?
reuse the method
What console method allows you to inspect the properties of a DOM element object?
method dir of object console; console.dir()
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
gives the HTML time to load before any of the JavaScript loads, which can prevent errors
What does document.querySelector() take as its argument and what does it return?
arg: a string css selector
return: first of the matching elements from top
What does document.querySelectorAll() take as its argument and what does it return?
arg: a string css selector
return: node list of one element object for each element that matches the css selector
dom node?
an object with methods and properties; every node is a descendant of the document node
Why do we log things to the console?
.
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener()
Are all possible parameters required to use a JavaScript method or function?
no
What object is passed into an event listener callback when the event fires?
the event object
What is a callback function?
a function passed into another function as an argument
What object is passed into an event listener callback when the event fires?
the event object; just a report on that event