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

you can use the 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

the first one is the name of the attribute, and the second one is the value(a string) for 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

there are three steps, first create a new element using the createElement() method. step 2 is to give it content using createTextNode()(this step is optional), step 3 is to add it to the DOM by using 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

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

A

it saves a lot of work creating html structure and its content. and it’s easier to control the content .

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