DOM Creation Flashcards

1
Q

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

A

It does not

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

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

A

You pass in attributes as strings and then the value of 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 node
  2. Create the text node
  3. Add the text node to the element node
    4 . Add the element to the DOM tree
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 is for updating the value 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

Using setAttribute() or using 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 functio to do create something (like the work of creating a DOM tree)?

A

Functions are reusable and are easier to read

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