Ver Mensaje Individual
  #2 (permalink)  
Antiguo 16/11/2010, 07:01
Dany_s
 
Fecha de Ingreso: diciembre-2009
Ubicación: Misiones
Mensajes: 867
Antigüedad: 14 años, 5 meses
Puntos: 65
Respuesta: Duda con arreglo

porque aca arreglo.push estas agregando valores, al volver agrega a los anteriores, deberias resetearlo después de agregar a recorridos[i]

yo lo haria asi

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.         <script>
  5.             $( function(){
  6.                 var arreglo = new Array();
  7.                 var recorridos = new Array();
  8.                 $("#table tbody tr").each(function(){
  9.                     id = $('td:eq(0)', this).text();
  10.                     otroCampo = $('td:eq(1)', this).text();
  11.                     recorridos.push( new Array(id, otroCampo) );
  12.  
  13.                 });
  14.  
  15.                 for (j = 0 ;j < recorridos.length; j++){
  16.                    alert ('TR' + j + '- Clave 1: ' + recorridos[j][0] + ' - Calve 2: ' + recorridos[j][1]);
  17.                }
  18.  
  19.            });
  20.        </script>
  21.     </head>
  22.  
  23.     <body>
  24.         <table id="table">
  25.             <tbody>
  26.                 <tr>
  27.                     <td>id1</td>
  28.                     <td>otro1</td>
  29.                 </tr>
  30.                 <tr>
  31.                     <td>id2</td>
  32.                     <td>otro2</td>
  33.                 </tr>
  34.                 <tr>
  35.                     <td>id3</td>
  36.                     <td>otro3</td>
  37.                 </tr>
  38.             </tbody>
  39.         </table>
  40.     </body>
  41. </html>