DOM Query Flashcards
Why do we log things in the console?
debugging purposes.
What is a “model”?
a copy 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?
referring to the data type object in javascript.
What is a DOM tree?
is an element with all of its contents and objects represented in a dom tree.
Give two examples of document methods that retrieve a single element from the dom.
getElementById() and document.querySelector()
Give one example of a document method that retrieves multiple elements from the DOM at once.
document.querySelectorAll()
Why might you want to assign the return value of a DOM query to a variable?
If you’re going to use it many times in your javascript.
What console method allows you to assign the return value of a DOM query to a variable?
console.dir()
Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?
so that when the webpage loads all the content of the web page has been loaded before the script.
What does document.querySelector() take as its argument and what does it return?
it takes a string element with css selectors and returns their values.
What does document.querySelectorAll() take as its argument and what does it return?
CSS selectors and it returns a NodeList
What is the purpose of events and event handling?
they’re listening for specific events or waiting. events are functions that “handle” the function that javascript is listening for.
Are all possible parameters required to use a Javascript method or function?
What method of element objects lets you set up a function to be called when a specific type of event occurs?
create .addEventListener, the string
What is a callback function?
a function which is to be executed after another function has finished execution.
What object is passed into an event listener callback when the event fires?
an object with a huge set of properties that set an event to occur.
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
it’s the element where the listener occured. log it out and look where it is.