mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
Exercise
If you don't already have the app running, start it with npm run static from the root of the frontend-bootcamp folder. Click the "exercise" link under day 1 step 3 to see results.
Update Navigation
- Add an
onclickattribute to all three buttons in the navigation. - In each
onclickcall thefilterfunction. In our function we need a reference to the clicked button, so pass in the keywordthisas the only parameter.
Write an updateRemaining function
- Get a reference to the span with the
remainingclass, and store it in a variable. - Use
querySelectorAllto get all of the todos. - Set the
innerTextof the remaining span to the length of those todos. - Add
updateRemaining()to the end of theaddTodofunction.
Write a clearCompleted function
- Get a reference to all of the todos with
querySelectorAll. - Use a
for (let todo of todos)loop to iterate over each todo. - Inside the for loop write an
ifstatement to test if theinputinside of the todo has a checked value of true.Hint: you can use
querySelectoron any HTML element to find matching child elements. - Call
todo.remove()for any todo whose input is checked. - After the loop is done, run
updateRemaining(). - Attach
clearCompleted()function to theonclickof the footer button. - Test it out!