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

265
Views
¿Cómo hago que funcione el botón que también se crea con el elemento de la lista? Quiero que elimine el elemento actual de la matriz. Cada artículo tiene su propio botón.

Traté de crear un evento onclick, pero no pasó nada

 let myWork = [] const submitEl = document.getElementById("submit-el") const clearEl = document.getElementById("clear-el") const listEl = document.getElementById("list-el") const textEl = document.getElementById("text-el") submitEl.addEventListener("click", function () { myWork.push(textEl.value) renderItems() }) clearEl.addEventListener("click", function () { myWork.pop() renderItems() }) function renderItems() { let listItems = "" for (let i = 0; i < myWork.length; i++) { listItems += `<li>${myWork[i]} </li> <button>Done</button>` } listEl.innerHTML = listItems }

¿Cómo hago para que este botón se elimine solo?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Si entiendo su pregunta, desea que el botón "Listo" elimine su propia línea al hacer clic.

Como una solución rápida, puede escribir:

 listItems += `<li>${myWork[i]} </li> <button onclick="deleteWorkByIndex(${i})>Done</button>` function deleteWorkByIndex(index) { myWork.splice(index, 1); // Delete the item n°{index} renderItems(); }
about 4 years ago · Santiago Gelvez Report
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!