He agregado la variable li usando querySelectorAll, pero cuando intento agregarle un detector de eventos para cambiar el estilo textDecoration a line-through, no tengo ningún éxito. ¿Algunas ideas?
// Variables let addBtn = document.querySelector("#addBtn"); let input = document.querySelector("#input"); let ul = document.querySelector("ul"); let li = document.querySelectorAll("li"); let completeBtn = document.querySelector("#complete-btn"); // Functions function inputLength() { return input.value.length; } function createListElement() { let li = document.createElement("li"); li.appendChild(document.createTextNode(input.value)); ul.appendChild(li); input.value = ""; } function addListAfterClick() { if (inputLength() > 0) { createListElement(); } } function addListAfterKeypress(e) { if (inputLength() > 0 && event.keyCode === 13) { createListElement(); } } function done() { li.style.textDecoration = "line-through"; } // Event Listeners addBtn.addEventListener("click", addListAfterClick); input.addEventListener("keypress", addListAfterKeypress); // I would like to add an event listener here so that the li elements textDecoration is changed to "line-through" completeBtn.addEventListener("click", function complete() { alert("Congratulations! You won't starve this week."); console.log(completeBtn); completeBtn.style.display = "none"; });