DOM Manipulation Flashcards
Why is storing information about a program in variables better than only storing it in the DOM?
It is easier to access variables. If information was only stored in the DOM, you’d have to query the DOM every time you want to access the information.
Is the event parameter of an event listener callback always useful?
Not always.
What is the className property of element objects?
It is a string containing the value of the class attribute on that element.
How do you update the CSS class attribute of an element using JavaScript?
By using the className property to change or retrieve the class applied on the element.
What is the textContent property of element objects?
It is the text content of the element and any child element as a string.
How do you update the text within an element using JavaScript?
By using the textContent property. Text can be updated by assigning it a new value.
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.