dom-querying Flashcards

1
Q

Why do we log things to the console?

A

Debugging and an easy way to inspect your variables in the browser

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

It represents the entire page and corresponds to the document object

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

Each node is an object with methods and properties

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

What is a DOM Tree?

A

A tree of objects called nodes which can be accessed through the tree

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

getElementById(), querySelector()

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

getElementsByClassName(), getElementsByTagName(), querySelectorAll()

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

To store the location of the element within the dom tree; so that you can use the same elements more than once and to save the browser time looking through the dom tree to find the same elements 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()

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

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

A

So that the HTML content loads first and a DOM tree can be created in the browsers’ memory

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

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

A

A string containing one or more selectors to match, an element object representing the first element in the document that matches the specified set of CSS selectors (or null if there are no matches)

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

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

A

A string containing one or more selectors to match, a non-live NodeList containing one element object for each element that matches at least one of the specified selectors (or an empty NodeList if no matches)

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