Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
delete rows dynamically using jquery problem. The new buttons don't delete the new rows

I am working on creating a table that I can add and delete rows from it dynamically using JQuery. My problem is that the only delete button that works fine is the first one ( the one with the first default row) later on whenever I add new rows the delete buttons for them doesn't remove the row. These are parts of my code. I will appreciate your help!

 <script>
            $(document).ready(function(){

                $("#add").click(function(){
                    var id="<input type='text' placeholder='Enter student id'>";
                    var name = "<input type='text' placeholder='Enter student name'>";
                    var timeSlot="<input type='text' placeholder='The time slot'>";

                    var row = "<tr> <td>"+id+"</td>" +
                         "<td>"+name+"</td>" + 
                         "<td>"+timeSlot+"</td>"+
                         " <td> <button class='remove' type='submit'>Remove Row</button> </td> </tr>";

                    $("tbody").append(row);
                });

                $("button.remove").click(function(){
                   $(this).parents("tr").remove();
                });
            });
        </script>
<table id="myTble">
            <thead>
                <tr>
                    <th>Student id</th>
                    <th>Student name</th>
                    <th>TimeSlot</th>
                    <th> <button id="add" type="submit">Add Row</button> </th>
                </tr>
            </thead>
              
            <tbody>
                <tr> 
                    <td>00000000</td>
                    <td>xxx xxxxx</td>
                    <td>9:00-10:00</td>
                    <td> <button class="remove" type="submit">Remove Row</button> </td>
                </tr>
            </tbody>

        </table>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda