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
cómo encontrar un td por índice en jquery

¿Cómo puedo cambiar el html interno obteniendo elemento por índice?
quiero cambiar el contenido de las celdas de acuerdo con sus valores de índice

 <table> <tr><td></td><td></td></tr> <tr><td></td><td></td></tr> <tr><td></td><td></td></tr> </table>
 function LFLS() { // LFLS => load from local Storage for (i = 0; i < localStorage.length; i++) { key = localStorage.key(i);//it return values like ("1,2","2,5", etc.) console.log(key) row = key.split(",")[0]; col = key.split(",")[1]; //how to get the cell by row and col } }
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Como dijo Sakil, puedes usar eq(). Prueba esto:

 function LFLS() { // load from local Storage for (i = 0; i < localStorage.length; i++) { key = localStorage.key(i); row = key.split(",")[0]; col = key.split(",")[1]; // how to get the cell by row and col $("table tr").eq(row).children().eq(col).html('NEW VALUE') } }
about 4 years ago · Juan Pablo Isaza Report

0

Creo que necesitas los siguientes fragmentos.

Antes de tu bucle for

 const rows = $("table tr");

Después de obtener variables de fila y columna

 const cellToUpdate = rows[row].children[col];

Alternativamente, si está buscando hacer un bucle programático a través de la tabla, puede usar el siguiente fragmento.

 <script type="text/javascript"> const rows = $("table tr"); for( i = 0; i < rows.length; i++ ) { const currRow = rows[i]; const rowChildren = currRow.children; for( n = 0; n < rowChildren.length; n++ ) { const cell = rowChildren[n]; cell.innerHTML = "My new data for row: " + i + " in cell " + n; } } </script>
about 4 years ago · Juan Pablo Isaza Report

0

¿Algo en las líneas de abajo no va a funcionar para usted por alguna razón?

$("table tr:nth-of-type([your-row])).eq([your-col]).html([your_content]);

about 4 years ago · Juan Pablo Isaza Report
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!