Hello Coding Friends,
I’m a stop-and-go learner of Javascript, still a beginner, and I’m working on creating a to-do list app. Right now, the app successfully takes user input, creates and appends an li item (yay!)
Next, I would like for the user to be able to click on the new li item once the task has been completed and have it crossed off. This is the bit of code I’m struggling with:
// to cross off a completed item
const tasks = document.querySelectorAll('.to-do-list li');
// loops through each li element and listens for click
for (task of tasks) {
task.addEventListener('click', function() {
this.style.textDecoration='line-through';
});
}
You can see the app so far at https://codepen.io/srhbishop/pen/vYOPXBm.
Thank you!