dom creation Flashcards
Does the document.createElement() method insert a new element into the page?
no, it saves the element to a variable
How do you add an element as a child to another element?
myParent.appendChild(myChild);
What do you pass as the arguments to the element.setAttribute() method?
strings: name of attribute, value of attribute
What steps do you need to take in order to insert a new element into the page?
create element to variable and append child
What is the textContent property of an element object for?
gets and sets the text content for an element
Name two ways to set the class attribute of a DOM element.
setAttribute() and className property
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
They are callable and repeatable
They can alter the page