DOM Creation Flashcards
Does the document.createElement() method insert a new element into the page?
It does not
How do you add an element as a child to another element?
Using the appendChild() method
What do you pass as the arguments to the elemetn.setAttribute() method?
You pass in attributes as strings and then the value of the attribute
What steps do you need to take in order to insert a new element into the page?
- Create the element node
- Create the text node
- Add the text node to the element node
4 . Add the element to the DOM tree
What is the textContent property of an element object for?
It is for updating the value of an element
Name two ways to set the class attribute of a DOM element
Using setAttribute() or using the className property
What are two advantages of defining a functio to do create something (like the work of creating a DOM tree)?
Functions are reusable and are easier to read