dom-creation Flashcards
Does the document.createElement() method insert a new element into the page?
no it doesn’t; it simply creates an element node ready to be inserted stored in a variable
How do you add an element as a child to another element?
the appendChild method
What do you pass as the arguments to the element.setAttribute() method?
the attribute name and value, respectively
What steps do you need to take in order to insert a new element into the page?
create the element, set the element’s text content (optional), append the element to a parent node
What is the textContent property of an element object for?
to set the element node’s text content
Name two ways to set the class attribute of a DOM element.
setAttribute method, className method
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
it is faster since you can automate it and use it for different purposes