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

402
Vistas
How to get row and column name of a selected checkbox inside a table cell using javascript

When I select a checkbox, it should give me the time (row) and day (column) value using javascript. If possible I should put these selected values into two separate arrays for time and day.

For example:

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

0

$("input[type=checkbox]").change(function() {
    if (this.checked) {
        let checkedCol = this.closest('tr').cells[0];
        let time = checkedCol.textContent;
        let colInd = parseInt($(this).parent().index());
        let day = $(this).closest('table').find('tr:first').find("td").eq(colInd).text();
        alert("Time : " + time + "  Day : " + day);
    }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr>
  <td></td>
  <td>Mon</td>
  <td>Tue</td>
</tr>
<tr>
  <td>8-12</td>
  <td><input type="checkbox" name="" value="1"></td>
  <td><input type="checkbox" name="" value="1"></td>
</tr>
<tr>
  <td>12-17</td>
  <td><input type="checkbox" name="" value="1"></td>
  <td><input type="checkbox" name="" value="1"></td>
</tr>
</table>

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