dom-creation Flashcards

1
Q

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

A

No

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

appendChild() method

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 attribute, value to assign to 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

Create the element with createElement() method, get its content with setAttribute() or textContent() methods as necessary, add it to the dom with appendChild() method

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

Can get or set the text of an element

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

setAttribute() method or className property

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 so that you don’t have to write the function multiple times. It is also easier to test.

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