dom-querying Flashcards

1
Q

Why do we log things to the console?

A

to make sure out code is working and doing what we want it to do. sort of like a progress update for testing and tracking

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

What is a “model”?

A

a respresentation of a structure, in this case its a representation of the html structure aka the DOM tree

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 doc

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 objects in this case are the html element representations that make up the DOM tree

a javascript representation of an html structure within a browser

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

What is a DOM Tree?

A

the way a browser structures its representation of an html structure

an element plus all of its content and configuration.

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

getElementsByClass();
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

in the event that you need to call on it more than once so that you aren’t wasting effort

so it doesn’t have to search the dom tree every time you need it

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

because the HTML would need to finish loading before the JavaScript if you are planning to access the html from a JavaScript file

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

it takes a css selector and returns the first matching element

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

it takes a css selector and returns a node list containing all matching elements

nodelists are not arrays or elements, its a js object created to hold a list of dom elements. its just data that you can iterate through

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