dom-querying Flashcards

1
Q

Why do we log things to the console?

A

“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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a “model”?

A

The model is called a DOM tree, and it is stored in the browsers’ memory.
It consists of four main types of nodes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which “document” is being referred to in the phrase Document Object Model?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the word “object” referring to in the phrase Document Object Model?

A

“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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a DOM Tree?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Give two examples of document methods that retrieve a single element from the DOM.

A

Two examples of document methods that retrieve a single element from the DOM:
getElementByld (‘id’)
querySelector (‘css selector’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Give one example of a document method that retrieves multiple elements from the DOM at once.

A

One example of a document method that retrieves multiple elements from the DOM at once:
getElementsByClassName( ‘class’ )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why might you want to assign the return value of a DOM query to a variable?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What console method allows you to inspect the properties of a DOM element object?

A

“Console.dir()” allows you to inspect the properties of a DOM element object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does document.querySelectorAll() take as its argument and what does it return?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does document.querySelector() take as its argument and what does it return?

A

the first Element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly