mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
1.2 KiB
1.2 KiB
Exercise
Update Navigation
- Add an onclick attribute to all 3 buttons in the navigation.
- For each onclick call the
filterfunction. In our function we need a reference to the clicked button, so pass in the keywordthisas the only parameter.
Write updateRemaining function
- Get a reference to the span with the
remainingclass, and store it in a variable. - Use querySelectorAll to get all of the todos.
- Set the
innerTextof the remaining span to the length of those todos. - Add updateRemaining() to end of addTodo function.
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 querySelector on any HTML node to find child elements within.
- Call
todo.remove()for any todo whos input check is true. - After the loop is done, run
updateRemaining(). - Attach this function to the footer button.
- Test it out!