DOM Flashcards

1
Q

Why do we log things to the console?

A

We log things to the console for clarification and for debugging

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

What is a “model”?

A

A model is a representation of something.

Of the DOM(document object model), the “model” refers to the model of the web page that the browser creates when it loads a page.

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

The HTML document

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

The word object is a javascript object that is representing all the data and content within the HTML document.

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 Tree is the model that is created by the browser when it loads the web page, and it is stored in the browser’s memory.

The DOM tree consists of nodes. Each node is an object with methods and properties. (the document & elements and all of their contents are branches within the tree)

The DOM tree consists of four main types of nodes —
		the document node
		element nodes
		attribute nodes
		text nodes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Give two examples ofdocumentmethods that retrieve a single element from the DOM.

A

querySelector()

getElementByID()

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

Give one example of adocumentmethod that retrieves multiple elements from the DOM at once.

A

querySelectorAll()
getElementsByClassName()
getElementsByTagName()

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

If you want to work with an element more than once, it is helpful to store the result of the DOM query in a variable.

The variable would hold the reference point (the address) of the element you’re searching for. Storing that reference point in a variable will prevent the computer from searching for the same element multiple times. (Repeating DOM queries unnecessarily can really slow down an application.)

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

Whatconsolemethod allows you to inspect the properties of a DOM element object?

A

console.dir()

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

Why would atag need to be placed at the bottom of the HTML content instead of at the top?

A

Because the browser reads the webpage from top to bottom. So, in order for the browser to read all the element manipulation done within javascript, it first must read the creation and content of the element.

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

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

A

document.querySelector() uses CSS selector syntax to select one or more elements.

This method returns only the first of the matching elements.

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

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

A

document.querySelectorAll() uses CSS selector syntax to select one or more elements and returns all of those that match.

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

What are DOM queries?

A

Methods that find elements in the DOM tree.

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

Why do we log things to the console?

A

For clarification and for help in debugging.

Logging things to the consoles helps us to ensure that our code is functioning the way it was intended to.

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