DOMS Flashcards
What is a “model”?
a representation of an actual thing
Which “document” is being referred to in the phrase Document Object Model?
a model of the HTML document that gets loaded to the browser as a javascript object
What is the word “object” referring to in the phrase Document Object Model?
each html element node. Has its own methods and properites and can be identified with element name id/class
What is a DOM Tree?
the tree comprised of nodes with html elements and its classes
Give two examples of document methods that retrieve a single element from the DOM.
document. querySelector() –> use this one
document. getElementByID()
Give one example of a document method that retrieves multiple elements from the DOM at once.
document. ->
getElementsByClassName()
getElementsByTagName()
querySelectorAll() –> use this one
Why might you want to assign the return value of a DOM query to a variable?
to recall it later
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?
the browser needs to parse all of the elements in the HTML page before the JavaScript code can access them.
What does document.querySelector() take as its argument and what does it return?
What does document.querySelectorAll() take as its argument and what does it return?
querySelector() -> string class, id, element but only returns the first match -> only returns one
querySelectorAll() -> css selector -> returns all that match
What is the purpose of events and event handling?
Events are actions or occurrences that happen in the system you are programming, which the system tells you about so your code can react to them.
Are all possible parameters required to use a JavaScript method or function?
no
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?
function that is put as an argument
runFunction(function)
What object is passed into an event listener callback when the event fires?
an event listener