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

183
Views
Quiero agregar un botón que tenga una identificación única en una tabla

Quiero agregar un botón en esta tabla. Puedo agregarlo con un código simple como este, pero veo que necesito tener una identificación única para cada botón cada vez que hago clic en el botón Agregar. Cómo puedo hacerlo. Por favor ayuda, muchas gracias.

 var btn = document.querySelector("#btn-add"); btn.addEventListener("click", function() { var tb = document.querySelector("#tb"); var test = document.querySelector("#test"); var test2 = document.querySelector("#test2"); var r = tb.insertRow(2); var c1 = r.insertCell(0); var c2 = r.insertCell(1); var c3 = r.insertCell(2); var c4 = r.insertCell(3); c1.innerHTML = test.value; c2.innerHTML = test2.value; c3.innerHTML = "<button>add</button>"; c4.innerHTML = "<button>delete</button>" })
 table, th, td { border: 1px solid black; }
 <input type="text" id="test"> <input type="text" id="test2"> <table id="tb"> <tr> <th>1</th> <th>2</th> <th>3</th> <th>4</th> </tr> <tr> <td>1</td> <td>2</td> <td>3</td> <td>4</td> </tr> </table> <button type="button" id="btn-add">add</button>

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!