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() method
What do you pass as the arguments to the element.setAttribute() method?
Name of attribute, value to assign to the attribute
What steps do you need to take in order to insert a new element into the page?
Create the element with createElement() method, get its content with setAttribute() or textContent() methods as necessary, add it to the dom with appendChild() method
What is the textContent property of an element object for?
Can get or set the text of an element
Name two ways to set the class attribute of a DOM element.
setAttribute() method or className property
What are two advantages of defining a function to create something (like the work of creating a DOM tree)?
Reusability so that you don’t have to write the function multiple times. It is also easier to test.