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

340
Views
¿Por qué mi botón creado por JS no funciona?

Se supone que este código me permite agregar líneas a una tabla que contiene valores de nombre, fecha y cantidad de dinero y, al final de cada línea, también crea un botón que me permite eliminar esa línea específica.

 const nameEl = document.getElementById("name-el") const dateEl = document.getElementById("date-el") const amountEl = document.getElementById("amount-el") const tableEl = document.getElementById("table-el") const buttonEl = document.getElementById("button-el") let myExpense = [] buttonEl.addEventListener("click", function() { myExpense.push({ name: nameEl.value, date: dateEl.value, amount: amountEl.value }) renderTable() }) function renderTable() { for (let i = 0; i < myExpense.length; i++) { tableEl.innerHTML += ` <tr> <th>${myExpense[i].name}</th> <th>${myExpense[i].date}</th> <th>${myExpense[i].amount}</tr> </th> <button id="deleteThis">X</button> ` } } function deleteThis(index) { myExpense.splice(index, 1); renderTable(); }
 /* no css */
 <!-- no HTML -->

Quiero que este botón creado por JS se elimine a sí mismo y a su respectiva línea de la tabla, pero por algún motivo no funciona.

about 4 years ago · Juan Pablo Isaza
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!