dom manipulation Flashcards
What is the className property of element objects?
allows you to grab or set the class of an element
How do you update the CSS class attribute of an element using JavaScript?
element.className = ‘class’
use += ‘ newClass’ to add instead of replace
What is the textContent property of element objects?
Any text contained by the element
How do you update the text within an element using JavaScript?
element.textContent = ‘new text content’
Is the event parameter of an event listener callback always useful?
no
Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?
more complicated
Why is storing information about a program in variables better than only storing it in the DOM?
DOM is only a model, variables are part of the code