← Code

The DOM and the browser console

Make a real web page react with JavaScript: find elements, change them, listen for clicks and typing, and keep a list and a score, ending in a quiz page you build.

Start1. Find and change

Change the page

Find an element, change it, and run code when someone clicks.

1Find and changeNot started
2Click eventsNot started
3Classes and themesNot started

Building blocks

Classes, inputs, lists of elements and a score the page remembers.

4InputsNot started
5Building a listNot started
6A page that keeps scoreNot started

Final challenge: a quiz page

Build a quiz that checks answers and keeps score. Two optional lessons show the real browser console and loading data with fetch.

7Final challenge: a quiz pageNot started

Put it all together: a list of questions as data, buttons made for each choice, a score that remembers, and feedback on every click.

  1. Predict
  2. Run
  3. Investigate › Which piece does what?
  4. Investigate › A fourth question
  5. Investigate › Spot the bug
  6. Modify › Colours
  7. Modify › Out of three
  8. Your own quiz
  9. Where this leads
Start lesson
8The real browser console OptionalNot started
9Data from the web: fetch OptionalNot started

Load JSON data with fetch, wait for it with await, show it on the page, and fall back to a saved copy when the network fails.

  1. Predict
  2. Run
  3. Investigate › Put it in order
  4. Investigate › Why await?
  5. Investigate › Spot the bug
  6. Modify › Rain
  7. Modify › Live, with a plan B
  8. The hottest day
  9. Where this leads
Start lesson
10Saving between visits OptionalNot started

Keep data when the page is closed with localStorage: save text when something changes, load it when the page opens, and save lists as JSON.

  1. Predict
  2. Run
  3. Investigate › Which line does what?
  4. Investigate › Start again
  5. Investigate › Spot the bug
  6. Modify › Really start again
  7. Modify › Remember a name
  8. A best score that lasts
  9. Where this leads
Start lesson

Progress is saved in this browser only. Nothing is sent anywhere.

For teachers: Teacher guide (notes, answers, solutions, slides and worksheets)