dom-creation Flashcards
1
Q
Does the document.createElement() method insert a new element into the page?
A
No, it only creates the Element. –> appendchild does!!!
2
Q
How do you add an element as a child to another element?
A
Appendchild
3
Q
What do you pass as the arguments to the element.setAttribute() method?
A
Name (type, class) and the value
4
Q
What steps do you need to take in order to insert a new element into the page?
A
- createElement.
2. appendChild
5
Q
What is the textContent property of an element object for?
A
- text Content to check or set new text to it (set or get textContent)
6
Q
Name two ways to set the class attribute of a DOM element.
A
- .set Attribute
2. className
7
Q
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
A
- get back the values directly. resuable and can slot in anywhere.
- Write a function that can be adpated in different situation.
- super easy to test. Call the function.