DOM Flashcards
why do we log things to the console?
during development, keep track of results
check functionality and data verification
what is a “model?”
a system or thing used as an example to follow or imitate
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?
JavaScript objects
what is a DOM tree?
a model of a web page consisting of all elements and their nodes
give two examples of document methods that retrieve a single element from the DOM
getElementbyID(‘id’)
querySelector(‘css selector’)
give one example of a document method that retrieves multiple elements from the DOM at once
querySelectorAll(‘css selector’)
why might you want to assign the return value of a DOM query to a variable?
variable stores a reference to the object in the dom tree
what console method allows you to inspect the properties of a DOM element object?
console.dir()
why would a < script > tag need to be placed at the bottom of the HTML content instead of at the top?
browser needs to parse all of the elements in the HTML before javascript code can access them
what does document.querySelector() take as its argument and what does it return
takes elements within the document that matches the specified selector, or gorup of selectors
returns an HTMLelement object representing the first element in the document that matches the CSS seleector, or null is returned if there is no match
what does document.querySelectorAll() take as its argument and what does it return?
takes CSS selector as argument
rreturns a static NodeList representing a list of the document’s elements that match the specified group of selectors
why do we log things to the console?
keep track of data
functionality
data verification
what is the purpose of events and event handling?
keep track of how the user interacts with the web page
what do [] square brackets mean in function and method syntax documentation?
brackets are optional arguments
what method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener()