dom-creation Flashcards

1
Q

Does the document.createElement() method insert a new element into the page?

A

No, it just creates it

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

How do you add an element as a child to another element?

A

element.appendChild()

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

What do you pass as the arguments to the element.setAttribute() method?

A

name of the attribute to be set, value to assign the attribute

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

What steps do you need to take in order to insert a new element into the page?

A
  1. create the element with createElement()
  2. Give it content (optional) with createTextNode()
  3. Add it to the DOM ( appendChild() )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the textContent property of an element object for?

A

it either returns the value of the text in the node or it assigns text to the node.

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

Name two ways to set the class attribute of a DOM element.

A

className and classList

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

What are two advantages of defining a function to create something (like the work of creating a DOM tree)?

A

Reusability, Separation of concerns, improved testability

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