DOM Flashcards
Why do we log things to the console?
To check that the correct output is being made, debugging, knowing what you’re working with
What is a “model”?
Represents the structure of the document. Recreation, representation
Which “document” is being referred to in the phrase Document Object Model?
The HTML document
What is the word “object” referring to in the phrase Document Object Model?
the data type object in javascript
What is the DOM?
Dom is a javascript object that has been constructed to recreate the content of the HTML document
What is a DOM Tree?
An element and all of its configurations and content represented as an object in the dom.
Give two examples of document methods that retrieve a single element from the DOM.
getElementById() and document.querySelector()
Give one example of a document method that retrieves multiple elements from the DOM at once.
document.querySelectorAll()
Why might you want to assign the return value of a DOM query to a variable?
If your script needs to use the same element more than once
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?
string of Css selector and returns only the first of the matching elements
What does document.querySelectorAll() take as its argument and what does it return?
Css selector and returns Nodelist(collection of nodes)/ all of those elements that match
Why do we log things to the console?
To see the result of our output, to know what we are working with
What is the purpose of events and event handling?
Event - something that occurred. Listener is waiting and calls event handler. The purpose of events is to react to them through event handling, the next step to do
Are all possible parameters required to use a JavaScript method or function?
no