Mostrar valores de la columna de una tabla HTML


<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
function recorrerFila(){
    $("#tablaPersonas tbody tr").each(function (item) {
        var this_row = $(this);
        var numeroDocumento = $.trim(this_row.find('td:eq(1)').html());
        alert("numero documento : " + numeroDocumento);
    });
}
</script>
</head>
<body>
<input type="button" value="Mostrar Nombres" onclick="recorrerFila();">
<table id="tablaPersonas" border="1">
<thead>
<tr>
<th>Nro.Documento</th>
<th>Nombres</th>
</tr>
</thead>
<tbody>
<tr>
<td>12345678</td>
<td>Jorge</td>
</tr>
<tr>
<td>12345679</td>
<td>Christian</td>
</tr>
<tr>
<td>12345670</td>
<td>Mario</td>
</tr>
</tbody>
</table>
</body>
</html>

Comentarios

Entradas populares de este blog

Subir proyecto al repositorio existente en Bitbucket

Sonarqube : The component parameter is missing