DOM Javascript Flashcards

1
Q

access a form and its element by name

A

let el = document.forms[‘formName’][‘elName’]

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

focus a DOM element

A

elVariable.focus();

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

set a style on a DOM element

A

elVariable.style. = “new value”;

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

add or remove classes from a DOM element

A

elVariable.classList.add(‘styleName’);
elVariable.classList.remove(‘styleName’);
(there is also a .toggle() )

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

NodeList forEach()?

A

Doesn’t have forEach().

Use Array.from() to convert to an array, or use for …of loop

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