DOM Javascript Flashcards
1
Q
access a form and its element by name
A
let el = document.forms[‘formName’][‘elName’]
2
Q
focus a DOM element
A
elVariable.focus();
3
Q
set a style on a DOM element
A
elVariable.style. = “new value”;
4
Q
add or remove classes from a DOM element
A
elVariable.classList.add(‘styleName’);
elVariable.classList.remove(‘styleName’);
(there is also a .toggle() )
5
Q
NodeList forEach()?
A
Doesn’t have forEach().
Use Array.from() to convert to an array, or use for …of loop