DOM Creation Flashcards

1
Q

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

A

No, just makes it. Doesn’t exist on page until you use the append method.

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 theelement.setAttribute( )method?

A

Two arguments: name and value (both as strings)

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

Name two ways to set theclassattribute of a DOM element.

A

Element.setAttribute( )

Element.className

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

What is thetextContentproperty of an element object for?

A

To get text content or to set the text content of an element

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

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

A

createElement and then append it

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 do create something (like the work of creating a DOM tree)?

A

Defining a function allows for reusability so you don’t have to write the function over and over. Defined functions are also easy to test.

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