DOM Flashcards
Why do we log things to the console?
To debug our code
What is a “model”?
A model is a represention of something
Which “document” is being referred to in the phrase Document Object Model?
The document being referred to is the HTML document
What is the word “object” referring to in the phrase Document Object Model?
The Object refers to JavaScript objects
What is a DOM Tree?
A DOM tree is a nested tree of objects represesnting the HTML document
Give two examples of document methods that retrieve a single element from the DOM.
document. querySelector()
document. getElementById()
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?
for ease of access
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?
to wait for the DOM to load all its content
What does document.querySelector() take as its argument and what does it return?
a CSS selector, it returns an element node
What does document.querySelectorAll() take as its argument and what does it return?
a CSS selector, it returns a list of elements
What is the purpose of events and event handling?
To run function when certain conditions are meant
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()