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?
appendchild
What do you pass as the arguments to the element.setAttribute() method?
attribute name and attribute valiue
What steps do you need to take in order to insert a new element into the page?
create the element
Give it any text content or classes
append it to the document
What is the textContent property of an element object for?
to add text content to new elements
Name two ways to set the class attribute of a DOM element.
.setAttribute()
class list
class name
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
to be dry (don’t repeat yourself)