dom-creation Flashcards

1
Q

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

A

no it doesn’t; it simply creates an element node ready to be inserted stored in a variable

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

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 attribute name and value, respectively

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, set the element’s text content (optional), append the element to a parent node

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 set the element node’s text content

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, className method

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 is faster since you can automate it and use it for different purposes

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