DOM (Document Object Model) Flashcards
Why do we log things to the console?
Inspect value to debug - This is especially important for DOM
What is a “model”? (Not in relation to code)
A prototype or 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?
Objects in JavaScript
What is a DOM Tree?
JavaScript object for a HTML element including attributes, values, and its children elements
Give two examples of document methods that retrieve a single element from the DOM.
getElementByID
querySelector (preferred method)
Give one example of a document method that retrieves multiple elements from the DOM at once.
querySelectorAll (preferred method)
Why might you want to assign the return value of a DOM query to a variable?
Easier access so you can search for it and use it again in the future
What console method allows you to inspect the properties of a DOM element object?
console.dir (which stands for directory)
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
HTML content needs to load the data before using DOM or else it will have nothing to work with
What does document.querySelector() take as its argument and what does it return?
String that consists of a CSS selector and returns the first matching element
What does document.querySelectorAll() take as its argument and what does it return?
String that consists of a CSS selector and returns all those that match (node list)
What is the purpose of events and event handling?
Creating a reaction in response to something happening.
Are all possible parameters required to use a JavaScript method or function?
No some are optional
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener