Deleting Completed Items

In this lesson, we will add ​the ability to delete items from the list in the application once the "to do" tasks have been completed.

Create Buttons Dynamically for Each Item #

Remember when we looped through our collection of items and placed each to-do inside a paragraph tag, then appended that to a container element? We are going to create buttons inside that loop with a similar method. We use JavaScript to dynamically create them and add the attribute of data to each one, which will hold the id of that item. We will use a click event to read that attribute and delete the correct item.

Get hands-on with 1400+ tech skills courses.