DOM Flashcards
What is a “model”?
A visual representation
Which “document” is being referred to in the phrase Document Object Model?
the HTML doc
What is the word “object” referring to in the phrase Document Object Model?
a JavaScript Object
What is a DOM Tree?
An element plus all its content and its configuration
Give two examples of document methods that retrieve a single element from the DOM.
getElementById() and preferably 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?
So you don’t need to keep looking it upon each reuse
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?
So it loads every element first before it loads up the javascript
Why would a
tag need to be placed at the bottom of the HTML content instead of at the top?
So it loads every element first before it loads up the javascript
What does document.querySelector() take as its argument and what does it return?
Takes CSS syntax as a string, returns the first element that it finds matching that selector
What does document.querySelectorAll() take as its argument and what does it return?
It takes a string and brings back a nodeList
What is the purpose of events and event handling?
To make the document behave with interactions
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?
taking a function definition and passing it around