dom-manipulation Flashcards

1
Q

What is the className property of element objects?

A

The className property of element objects contains the class attribute value of the html element in string form. This property can be accessed and changed to apply other class styling or remove certain styles.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you update the CSS class attribute of an element using JavaScript?

A

To access the CSS class attribute of an element using JavaScript you grab an element from the DOM. Then you take the DOM element object and select the property of “className”: $button.className = “hot-button cold”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the textContent property of element objects?

A

The textContent property of element objects is the text content that appears between the start tag and closing tag of the element in HTML.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you update the text within an element using JavaScript?

A

To update the text within an element using JavaScript you grab the element location from the DOM and store is in a variable then you access the textContent property from that element and assign it a new value: $button = document.querySelector(.’button’);
$button.textContent = “Click me”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Is the event parameter of an event listener callback always useful?

A

The event parameter of an event listener callback is not always useful if you plan on manipulating something other than the clicked element when that element is clicked.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why is storing information about a program in variables better than only storing it in the DOM?

A

Storing information about a program in variables is better than storing it in the DOM because the DOM takes more time to query and pass through the different elements in the NodeList. The code stays more organized and is faster to code if all the values are kept in variables within JavaScript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly