dom-querying Flashcards
Why do we log things to the console?
The JavaScript console is a debugging tool. It is where the browser prints errors and warnings as they occur in your JavaScript code.
What is a “model”?
An easily digestible representation of something larger
Which “document” is being referred to in the phrase Document Object Model?
A web page is a document that can be either displayed in the browser window or as the HTML source. In both cases, it is the same document but the Document Object Model (DOM) representation allows it to be manipulated. As an object-oriented representation of the web page, it can be modified with a scripting language such as JavaScript.
What is the word “object” referring to in the phrase Document Object Model?
The HTML DOM model is constructed as a tree of Objects:
What is a DOM Tree?
interface that treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document.
Give two examples of document methods that retrieve a single element from the DOM.
getElementById() and querySelector()
Give one example of a document method that retrieves multiple elements from the DOM at once.
getElementsByClassName()
Why might you want to assign the return value of a DOM query to a variable?
To log it, change classes, have an easier way to access it
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?
The browser needs to parse all of the elements in the HTML page before the JavaScript code can access them.
What does document.querySelector() take as its argument and what does it return?
The Document method querySelector() returns the first Element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned. Takes a css selector as an argument
What does document.querySelectorAll() take as its argument and what does it return?
The Document method querySelectorAll() returns a static (not live) NodeList representing a list of the document’s elements that match the specified group of selectors.