Ver Mensaje Individual
  #8 (permalink)  
Antiguo 17/12/2010, 14:30
Dany_s
 
Fecha de Ingreso: diciembre-2009
Ubicación: Misiones
Mensajes: 867
Antigüedad: 14 años, 5 meses
Puntos: 65
Respuesta: Jquery trabajar con inputs dentro de td

otra forma creo que es más sencilla, creo un string del tr asi tengo todos los campos tal cual lo dejo por defecto y no hay que limpiarlos, cuando doy click en el botón con #agregar agrego la clase eliminar y borro el id, luego agrego la nueva fila

Código HTML:
Ver original
  1.     <head>
  2.         <title>Ejemplo</title>
  3.         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  4.     </head>
  5.         <script type="text/javascript">
  6.             $( function (){
  7.                
  8.                 newTr = '<tr>'+$('#laTabla tr').clone().html()+'</tr>';
  9.                 $('#agregar').live('click', function(){
  10.                     $(this).text("Eliminar").addClass('eliminar').removeAttr('id');
  11.                     $('#laTabla').append(newTr);
  12.                     return false;
  13.                 });
  14.  
  15.                 $('.eliminar').live('click', function(){
  16.                     $(this).closest('tr').remove();
  17.                     return false;
  18.                 });
  19.  
  20.             });
  21.         </script>
  22.     <body>
  23.  
  24.     <div>
  25.         <table id="laTabla">
  26.             <tr>
  27.                 <td><span class="item">Name</span></td>
  28.                 <td><input  type="text"  name="nombre[]" /></td>
  29.                 <td><input  type="text"  name="uno[]" /></td>
  30.                 <td><input  type="text"  name="dos[]" /></td>
  31.                 <td><select name="tres"><option>1</option><option>2</option</select></td>
  32.                 <td><select name="cuatro"><option>1</option><option>2</option</select></td>
  33.                 <td><select name="cinco"><option>1</option><option>2</option</select></td>
  34.                 <td><button id="agregar">Agregar</button></td>
  35.             </tr>
  36.         </table>
  37.     </div>
  38.  
  39.     </body>
  40. </html>