dom-querying Flashcards
Why do we log things to the console?
“console. log” specifically is a method for developers to write code to inconspicuously inform the developers what the code is doing.
To check whatever it is we are coding.
What is a “model”?
The model is called a DOM tree, and it is stored in the browsers’ memory.
It consists of four main types of nodes.
Which “document” is being referred to in the phrase Document Object Model?
When the browser loads a web page, it creates a model of the page in memory.
The DOM specifies the way in which the browser should structure this model using
a DOM tree.
What is the word “object” referring to in the phrase Document Object Model?
“object model” is used in the traditional object-oriented design sense: documents are modeled using objects, and the model encompasses not only the structure of a document but also the behavior of a document and the objects of which it is composed.
What is a DOM Tree?
The DOM is called an object model because the model (the DOM tree) is made of objects.
Each object represents a different part of the page loaded in the browser window.
Give two examples of document methods that retrieve a single element from the DOM.
Two examples of document methods that retrieve a single element from the DOM:
getElementByld (‘id’)
querySelector (‘css selector’)
Give one example of a document method that retrieves multiple elements from the DOM at once.
One example of a document method that retrieves multiple elements from the DOM at once:
getElementsByClassName( ‘class’ )
Why might you want to assign the return value of a DOM query to a variable?
You want to assign the return value of a DOM query to a variable because it saves the browser from having to look through the DOM tree and search for the same elements again and a again
What console method allows you to inspect the properties of a DOM element object?
“Console.dir()” allows you to inspect the properties of a DOM element object.
Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?
When you place your JavaScript at the bottom of your HTML body, it gives the HTML time to load before any of the JavaScript loads, which can prevent errors, and speed up website response time.
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.
What does document.querySelector() take as its argument and what does it return?
the first Element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned.