EjemplosDuoc.es.tl
  Table manipulación
 
Para manipular fila que seleccionó el usuario se debe tener enumerada mediante class o id (class para este ejemplo)

y utilizar el siguiente evento:

$('.tabla').on('click','table tbody tr td', function()
{
 
               columna = parseInt($(this).index());
idFila = this.closest("tr").className
 
alert($('.' + idFila + ' td').eq(columna).text());
});

El class permite saber la fila seleccionada y la columna con el método .eq, donde el número señalado como argumento es la columna.

o también

$("#myt tbody td").click(function() 
{
var rowIndex = $(this).parent().index('#myt tbody tr');
alert(rowIndex);
var tdIndex = $(this).index('#myt tbody tr:eq(' + rowIndex + ') td');
alert('Row Number: ' + (rowIndex) + '\nColumn Number: ' + (tdIndex));
  let id = $(this).closest('tr').find('td').eq(0).text();
$('.txtIdActividad').val(id);
alert($(this).text());
});








Primera columna es cero.
 
   
 
Este sitio web fue creado de forma gratuita con PaginaWebGratis.es. ¿Quieres también tu sitio web propio?
Registrarse gratis