DOM Flashcards
Why do we log things to the console?
So we can verify the outputs. Further, troubleshoot and
debugging.
What is a ”model”?
A model is a representation(or recreation) of something. In the case of DOM, it
is a copy of the page layout before any changes are applied
Which ”document” is being referred to in the phrase Document Object Model?
The document is the entire HTML document
What is the word ”object” referring to in the phrase Document Object Model?
The objects are JavaScript objects
What is a DOM Tree? A DOM Tree is a model of the HTML code.
It arranges the elements in a
HTML file by their elements and relationship to each other
Give two examples of document methods that retrieve a single element from the DOM.
We can use getElementById() and querySelector() to select single elements from the DOM
Give one example of a document method that retrieves multiple elements from the DOM at once.
getElementsByClassName(), getElementsByTagName(), or querySelectorAll()
Why might you want to assign the return value of a DOM query to a variable?
So we can console log and verify we selected the correct element or to use it to modify the page later on
What console method allows you to inspect the properties of a DOM element object?
console.dir() is used to inspect an element’s properties in the console
Why would a
tag need to be placed at the bottom of the HTML content instead of at the top?
It is placed at the bottom because a browser needs to run all of the HTML first before we can access them
What does document.querySelector() take as its argument and what does it return?
It takes in a string that must also be a valid CSS selector. It will return an element object that represents the first element in the document that matches the specified CSS selector
What does document.querySelectorAll() take as its argument and what does it return?
It takes in a string that must also be one or many valid CSS selectors separated by commas. It will return a list with the elements that corresponds to the CSS selectors
What is the purpose of events and event handling?
Events are used for detecting when a user interacts with a web page. Event handling is a way to respond to the user’s 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(’Event’,functionName), ’Boolean’ (default: false. Optional)