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

186
Vistas
row index and column index of a value in JQuery

I have a table and it has few values. I've assigned the highest value to a variable. Now I want to get the row index and column index of the cell that contain the value in the variable. How is it possible? I need to use jquery only.Any help is appreciated. Thnankyou.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Since you have not provided a reproducible code example,i have a code snippet for you,so you can modify it for your own needs,it gives you the cell index + row index of the highest number among all td cells,its not what you want but it gives you the logic you should follow (my opinion)

Keep in mind that indexes start at 0 (0,1,2,3...)

let allTd = []

document.querySelectorAll("td").forEach(td =>{
allTd.push(Number(td.innerText))
}) //create an array of all the numbers in td cells

let max = Math.max(...allTd) // find the highest number

document.querySelectorAll("td").forEach(td => {
  if (Number(td.innerText) === max) { 
  console.log(`Row index : ${td.closest("tr").sectionRowIndex}`) 
  console.log(`Cell index : ${td.closest("td").cellIndex}`)
  }
}) //compare highest number against all td cells then console.log row index and cell index of matching cell
<!DOCTYPE html>
<html>

<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
</head>

<body>
    <table class="table table-bordered text-center">
        <tbody>
            <tr>
                <td>6</td>
                <td>23</td>
                <td>13</td>
                <td>17</td>
                <td>44</td>
                <td>12</td>
            </tr>
            <tr>
                <td>3</td>
                <td>56</td>
                <td>67</td>
                <td>32</td>
                <td>20</td>
                <td>12</td>
            </tr>
            <tr>
                <td>15</td>
                <td>62</td>
                <td>13</td>
                <td>9</td>
                <td>77</td>
                <td>12</td>
            </tr>
        </tbody>
    </table>
</body>

</html>

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