Command Palette

Search for a command to run...

Hectal
Phase 9: Events
JavaScript · Exercise 3 of 6 PreviousNext
Intermediate

A to-do list with one listener

The Add form already adds new items. Now, with one click listener on #list (event delegation):

- Clicking an item's ✕ button removes that item.

- Clicking an item's text toggles the class done on its <li>.

It must also work for items added after the page loaded.

What Check tests

  1. ✕ removes its own item
  2. Clicking the text toggles done
  3. Items added later can be removed
  4. Items added later can be marked done
  5. Clicking empty space in the list causes no error

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.