Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
¿Pueden múltiples elementos en una lista de nodos responder a un detector de eventos?

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"; });
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!