dom-manipulation Flashcards
What is the className property of element objects?
The className property of the Element interface gets and sets the value of the class attribute of the specified element.
How do you update the CSS class attribute of an element using JavaScript?
You update the CSS class attribute of an element using JavaScript Element.setAttribute()
Sets the value of an attribute on the specified element. If the attribute already exists, the value is updated; otherwise a new attribute is added with the specified name and value.
To get the current value of an attribute, use getAttribute(); to remove an attribute, call removeAttribute().
What is the textContent property of element objects?
The textContent property sets or returns the text content of the specified node, and all its descendants. If you set the textContent property, any child nodes are removed and replaced by a single Text node containing the specified string.
How do you update the text within an element using JavaScript?
The textContent property of the Node interface represents the text content of the node and its descendants.
Is the event parameter of an event listener callback always useful?
Yes, the addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?
This assignment would have been more complicated, we would not know how many clicks we had.
Why is storing information about a program in variables better than only storing it in the DOM?
Storing information about a program in variables better than only storing it in the DOM as it is less work and it is cleaner.