I have a table in html with a checkbox in each row what I need is that when selecting the checkbox I take the value of a cell
<table>
<thead>
<th>Seleccionar</th>
<th>ejemplo</th>
<th>ehemplo</th>
</thead>
<tbody>
<tr>
<td><input type="checkbox" onclick="guardadatos();"></td>
<td>ejemplo</td>
<td>ejemplo</td>
</tr>
<tr>
<td><input type="checkbox" onclick="guardadatos();"></td>
<td>ejemplo</td>
<td>ejemplo</td>
</tr>
</tbody>
</table>
and the next function if I take the value of the cell but when selecting the other checkbox, I concatenate them and repeat the value, showing me an "undefined" each time the each is repeated
function guardadatos() {
$("input[type=checkbox]:checked").each(function(){
id = $(this).parents("tr").find("td").eq(1).html();
texto += id;
texto +="<br/>";
});
}