DOM Querying Flashcards

1
Q

Why do we log things to the console?

A

To check data (values of variables) and to verify if the codes are working correctly (double check functionality).
Logging things to console = developers way for verification.

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

What is a “model”?

A

It is a recreation of a system/thing used as an example to allow for imitation or to give another form of the system/thing.

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

Referring to objects in JavaScript

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

What is a DOM Tree?

A

A model of a webpage or portion of a webpage consisting of all of the elements and their nodes from most parental elements and downwards.

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

document. querySelector( )

document. getElementById( )

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

document. querySelectorAll( )

document. getElementsByClassName( )

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 save it to JavaScript in order to be able to work with it in the future.
Also less work for the browser. It won’t have to search through the entire HTML document again to find a value.

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

- - “dir” stands for directory

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

The browser has to load through all the codes in the HTML document before JavaScript code can access them.

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

Takes in a CSS selector as a ‘string’ as its argument and returns HTML element object.

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

Takes in a CSS selector as a ‘string’ as its argument and returns all matches as a nodelist.

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