Trace a basket button
Follow a user event through a state change and a visible update without running arbitrary code.
In this lesson
- It starts with a question. The basket count starts at 1. Two Add button events each add 1. What count should appear?
- The idea you will find. Connect the idea — The DOM is the page structure the script can update. An event handler responds to an action. In this simple design, the handler changes the stored count and then writes that value into the button. The trace shows supplied operations only: there is no live basket, payment, JavaScript editor or arbitrary execution.
- How you learn it. By doing: putting things in order.
- Length. 5 short steps. Progress saves on this phone.
Part of Build a market website
Plan a fictional Fiji market page, trace its interaction and test its form. Guided local activities work offline after download; this is not a free-form code editor.