Document Object Model Flashcards
Why do we log things to the console?
We log things to the console for debugging purposes.
What is a “model”?
The DOM Tree. Model is a representation/copy of the original.
Which “document” is being referred to in the phrase Document Object Model?
The HTML document is being referred to in the phrase Document Object Model.
What is the word “object” referring to in the phrase Document Object Model?
JavaScript object.
Each object represents a different part of the page loaded in the browser window.
What is a DOM Tree?
A tree/structure that shows all nodes/chunks of 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( )
document. getElementsByTagName( )
document. getElementsByClassName( )
Why might you want to assign the return value of a DOM query to a variable?
We might want to assign a return value of a DOM query to a variable so that it is reusable.
What console method allows you to inspect the properties of a DOM element object?
console.dir( )
Short for “directory”.
Why would a «a>script</a>> tag need to be placed at the bottom of the HTML content instead of at the top?
The «a>script</a>> tag needs to be placed at the bottom of the HTML content because the HTML content should load first on the browser.
What does document.querySelector( ) take as its argument and what does it return?
It takes a CSS selector as its argument and returns the first element with that CSS selector.
What does document.querySelectorAll( ) take as its argument and what does it return?
It takes a CSS selector as its argument and returns all elements with that CSS selector.
Why do we log things to the console?
For debugging purposes.
And to check if something is working.
What is the purpose of events and event handling?
The purpose is to add interactive properties to the website for the users.
Add dynamic content.
Ability to have something occur and do something in response.
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( )