DOM Manipulation Flashcards
What is the className property of element objects?
It gets and sets the class attribute of an element
How do you update the CSS class attribute of an element using JavaScript?
element.className = newValue
What is the textContent property of element objects?
The textContent property represents the text content of an element
How do you update the text within an element using JavaScript?
element.textContent = ‘newcontent’
Is the event parameter of an event listener callback always useful?
No because sometimes we do not need it
Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?
It would’ve been more complicated because then without it, we would have had to update the content with every loop
Why is storing information about a program in variables better than only storing it in the DOM?
It makes data more accessible and easier to use with JavaScript