I have a problem when I try to get the id
of a table here
$salida.="<table class='table'>
<thead>
<tr id='titulo'>
<th scope='col'>#Contrato</th>
<th scope='col'>Nombre</th>
<th scope='col'>Fecha Contrato</th>
<th scope='col'>Direccion</th>
<th scope='col'>Colonia</th>
<th scope='col'>Tipo de Cuota</th>
</tr>
</thead>
<tbody id='mytable'>";
while ($fila = $resultado->fetch_assoc()) {
$salida.="<tr style='cursor:pointer' onclick='al();'>
<td class="id">".$fila['NUMECONTRA']."</td>
<td>".$fila['NOMBREUSER']."</td>
<td>".$fila['FECHACONTR']."</td>
<td>".$fila['DIRECCUSER']."</td>
<td>".$fila['COLONIAUSE']."</td>
<td>".$fila['TIPOCUOTAS']."</td>
</tr>";
}
$salida.="</tbody>
</table>";
}else{
$salida.="NO HAY DATOS :(";
}
echo $salida;
and I want to be able to obtain the id data through js which I leave below.
$(document).ready(function() {
$('tr').click(function() {
alert($(this).find('td.id').text())
});
I did a test on a sheet of HTML
and it grabs me without problems.
<table>
<thead>
<tr>
<th>ID</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
</thead>
<tbody>
<tr >
<td class="id">45</td>
<td>Bruce</td>
<td>Almighty</td>
</tr>
<tr>
<td class="id">22</td>
<td>Bruce</td>
<td>Evans</td>
</tr>
</tbody>
</table>
The point is that on the PHP
sheet it does not grab me and I do not know what I'm doing wrong.