Additional reference: List of
HTML DOM Events
On the page you will see instructions for nine problems. Complete each problem by writing code in the .js
file to add the
specified behavior to the page. This is all running client-side in the browser, so reloading the page will reset it and clear
any changes that you have made at the console.
Cheat sheet, for your reference:
- Finding elements:
document.getElementById()
, document.getElementsByClassName()
- Changing text:
.innerHTML
, .innerText
- Changing attributes (they're just properties of the nodes!): e.g.
.style
, .src
- Working with HTMLCollections:
Array.from()
- Responding to events:
addEventListener()
,
- Changing classes:
.classList.add()
, .classList.remove()
- Form values:
.value
for textbox, have to look up for each type (e.g. select, radio)
Note that addEventListener
is preferred to directly assigning methods
(e.g. node.onclick =
) because it maintains an ordered list of handlers, not just one.
For the same reason, .classList
is preferred to direct assignment of the .class
property, although some very old browsers don't support it.