Dom Flashcards
Why do we log things to the console?
To debug
What is a “model”?
In this case, it’s the DOM tree displayed in a pattern or representation
Which “document” is being referred to in the phrase Document Object Model?
HTML
What is the “object” referring to in the phrase Document Object Model?
data type
Give two examples of document methods that retrieve a single element from the DOM?
getElementbyId(‘id’) and querySelector(‘css selector’)
Give one example of a document method that retrieves multiple elements from DOM at once.
querySelectorAll(‘css selector’)
Why might you want to assign the return value of a DOM query to a variable?
easier find and access
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?
The browser needs to parse all of the elements of the HTML page before the Javascript code can access them. Simply because HTML needs to load before the script.
What does document.querySelector() take as its argument and what does it return?
Uses CSS selector syntax that would select one or more elements. This method returns only the first of the matching elements.
What does document.quertySelectorAll() take as its argument and what does it return?
Uses a CSS selector syntax to select one or more elements and returns all of those that match (returns a node list)
What is a DOM Tree?
model for a family tree containing its attributes and values as well
What is the purpose of events and event handling?
So that we get a reaction and execute it
Are all possible parameters required to use a JavaScript method or function?
JavaScript function definitions do not specify data types for parameters. JavaScript functions do not perform type checking on the passed arguments. JavaScript functions do not check the number of arguments received.
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener()
What is a callback function?
gets called back into calling scope
What is the event.target? if you weren’t sure, how would you check? Where could you get more information about it.
target is where the event happens, console.log to check