dom-creation Flashcards
Does the document.createElement() method insert a new element into the page?
-no
How do you add an element as a child to another element?
- name the parent element
- appendChild method
- pass in the child element as the argument
What do you pass as the arguments to the element.setAttribute() method?
- element attribute
2. the value of that attribute
What steps do you need to take in order to insert a new element into the page?
- name the parent element (assuming the parent element is already on the page)
- appendChild method
- pass in the child element as the argument
What is the textContent property of an element object for?
The textContent property of the Node interface represents the text content of the node and its descendants.
Name two ways to set the class attribute of a DOM element.
- setAttribute method
2. className property of the Element interface
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
- dynamic
2. faster