DOM Flashcards
Why do we log things to the console?
To be aware of what our code Is doing and to make sure it has the outcome we want
What is a “model”?
A replication of a dom tree that is stored in the browser’s terminal
Which “document” is being referred to in the phrase Document Object Model?
the HTML document we are working on
What is the word “object” referring to in the phrase Document Object Model?
Each object refers to a different part of the page in the browser
What is a DOM Tree?
Collection of all the objects that make up the document
Give two examples of document methods that retrieve a single element from the DOM.
Document.getElementById() & 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 know that you need to call on that query multiple times
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 it can run the entire body to map out a tree before running our script
What does document.querySelector() take as its argument and what does it return?
Takes our class or id as an argument and returns the first instance of it
What does document.querySelectorAll() take as its argument and what does it return?
Takes all the elements or class we are looking for and returns a nodes list
What are some differences of Nodes list and HTML collection?
o Html collection will live update as you add things
o Nodes list is static and would not update
What is the purpose of events and event handling?
Events will trigger code. Event handling is to run blocks of code based on what happens on our webpage
What method of element objects let you set up a function to be called when a specific type of event occurs?
addEventListener()
What is a callback function?
A function passed into another function as an argument which is then invoked inside the outer function to complete some kind of action