dom-creation Flashcards
Does the document.createElement() method insert a new element into the page?
How do you add an element as a child to another element?
parent.appendChild(child)
What do you pass as the arguments to the element.setAttribute() method?
any value but it gets converted to a string. dom is made to work with multiple languages so it needs an easy. way to crossover
What steps do you need to take in order to insert a new element into the page?
query selector an element and assign to variable
variable.appendChild(newElement)
What is the textContent property of an element object for?
to retrieve current text to view it or change it
Name two ways to set the class attribute of a DOM element.
object.setAttribute(‘attribute’, value)
object.className = ‘value’
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
the function can be reused
and you can use the output in different locations for different jobs
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?