DOM Flashcards
Why do we log things to the console?
to check the output and help debug
What is a “model”?
representation of something
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?
the objects that comprise the structure and content of a document on the web
What is a DOM Tree?
Every element, attribute, and piece of text in the HTML is represented by its own DOM node, which makes up the DOM tree
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.
querySelectorAll
Why might you want to assign the return value of a DOM query to a variable?
To save the location; saves the browser from having to look for it every time.
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?
HTML document needs to loads first so javascript can manipulate DOM
What does document.querySelector() take as its argument and what does it return?
CSS selector string and returns only the first of the matching elements
What does document.querySelectorAll() take as its argument and what does it return?
CSS selector string and returns all elements that match
What is the purpose of events and event handling?
events inform us of user interaction and event handling instructs how to respond to the event
What do [] square brackets mean in function and method syntax documentation?
denotes optional
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?
event?
What object is passed into an event listener callback when the event fires?
event object
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
target property of event; mdn