DOM Flashcards
Why do we log things to the console?
Show check if our code is doing what its supposed to be doing; debugging
What is a “model”?
A representation of HTML on a webpage
Which “document” is being referred to in the phrase Document Object Model?
The document is the web page
What is the word “object” referring to in the phrase Document Object Model?
The different parts that the web page is made of
What is a DOM Tree?
A model of a web page made out of objects, with each object representing a different part of the web page
Give two examples ofdocumentmethods that retrieve a single element from the DOM.
querySelector method, getElementById method
Give one example of adocumentmethod that retrieves multiple elements from the DOM at once.
getElementsByClassName method
Why might you want to assign the return value of a DOM query to a variable?
You may need to work with the element more than once, so it makes it easily accessible
Whatconsolemethod allows you to inspect the properties of a DOM element object?
console.dir()
Why would atag 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 doesdocument.querySelector()take as its argument and what does it return?
It takes a selector for an element as the argument, and returns the first element on the document with that specified selector
What doesdocument.querySelectorAll()take as its argument and what does it return?
It takes a selector for an element and returns a Nodelist of all the elements on the page that match that selector
Why do we log things to the console?
To show that the code is doing what its supposed to be doing and to debug it
What is the purpose of events and event handling?
It gives a response to user input.
Are all possible parameters required to use a JavaScript method or function?
No