DOM Flashcards
Why do we log things to the console?
to verify and check code
What is a “model”?
a representation of something
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?
data type
What is a DOM Tree?
an element plus its content and configuration
Give two examples of document methods that retrieve a single element from the DOM.
querySelector and 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?
If you want to use the same DOM element more than once
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?
it needs to load all the elements
What does document.querySelector() take as its argument and what does it return?
it takes strings as an argument and returns the first element that matches
What does document.querySelectorAll() take as its argument and what does it return?
it takes a string as an argument and returns a nodelist
What is the purpose of events and event handling?
it allows the developer to make changes when the user does something
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?
taking a function definition and passing it down
What object is passed into an event listener callback when the event fires?
target
What is the event.target?
the element where the event originated on