LFZ DOM Quiz Flashcards
Why do we log things to the console?
For debugging purposes
What is a “model”?
a representation of something
Which “document” is being referred to in the phrase Document Object Model?
The HTML Document
Give two examples of document methods that retrieve a single element from the DOM.
getElementById, and querySelector
Give one example of a document method that retrieves multiple elements from the DOM at once.
getElementsByClassName
Why might you want to assign the return value of a DOM query to a variable?
To cache the location of the element so that the browser doesn’t have to find the element all over again
Why might you want to assign the return value of a DOM query to a variable?
To cache the reference of the element so that the browser doesn’t have to find the element all over again
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
So that the browser can analyze all of the data in the HTML
What console method allows you to inspect the properties of a DOM element object?
console.dir
What does document.querySelectorAll() take as its argument and what does it return?
it takes in a css selector and returns a nodelist of all elements with the css class
What does document.querySelector() take as its argument and what does it return?
it takes in a css selector and returns the first element it finds that matches
Why do we log things to the console?
For debugging things
What is the purpose of events and event handling?
To listen for things like mouse click, key down, etc
What is the purpose of events and event handling?
To listen for things like mouse click, key down, etc and then do things
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener