DOM Querying Flashcards
Why do we log things to the console?
To check data (values of variables) and to verify if the codes are working correctly (double check functionality).
Logging things to console = developers way for verification.
What is a “model”?
It is a recreation of a system/thing used as an example to allow for imitation or to give another form of the system/thing.
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?
Referring to objects in JavaScript
What is a DOM Tree?
A model of a webpage or portion of a webpage consisting of all of the elements and their nodes from most parental elements and downwards.
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. getElementsByClassName( )
Why might you want to assign the return value of a DOM query to a variable?
To save it to JavaScript in order to be able to work with it in the future.
Also less work for the browser. It won’t have to search through the entire HTML document again to find a value.
What console method allows you to inspect the properties of a DOM element object?
console. dir( )
- - “dir” stands for directory
Why would a < script > tag need to be placed at the bottom of the HTML content instead of at the top?
The browser has to load through all the codes in the HTML document before JavaScript code can access them.
What does document.querySelector( ) take as its argument and what does it return?
Takes in a CSS selector as a ‘string’ as its argument and returns HTML element object.
What does document.querySelectorAll( ) take as its argument and what does it return?
Takes in a CSS selector as a ‘string’ as its argument and returns all matches as a nodelist.