Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/10/2010, 14:21
Dany_s
 
Fecha de Ingreso: diciembre-2009
Ubicación: Misiones
Mensajes: 867
Antigüedad: 14 años, 4 meses
Puntos: 65
Respuesta: Clonar ultima fila de una tabla con jquery

porque queres modificar el id a la primer celda .children('td').eq(0)

¿para qué te sirve un id dinámico? si no sirven cuando creas estructuras fijas de forma dinámica

Código HTML:
Ver original
  1.     <title>Pruebas</title>
  2. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  3. $(function(){
  4.  
  5.     tabla = $('#tabla');
  6.     tr = $('tr:first', tabla);
  7.     $('#agregarFila').live('click', function (){
  8.         tr.clone().appendTo(tabla).find(':text').val('');
  9.     });
  10.  
  11.     $(".eliminarFila").live('click', function (){
  12.         $(this).closest('tr').remove();
  13.     });
  14.  
  15. });
  16. </head>
  17.  
  18.    
  19.     <table id="tabla">
  20.         <tr>
  21.             <td><input type="text" name="nombre"></td>
  22.             <td><input type="text" name="apellido"></td>
  23.             <td><input type="text" name="mail"></td>
  24.             <td><input type="button" value="Eliminar" class="eliminarFila"></td>
  25.         </tr>
  26.     </table>
  27.  
  28. <input type="button" value="Agregar" id="agregarFila">
  29.  
  30. </body>
  31. </html>

Última edición por Dany_s; 27/10/2010 a las 14:28