I've tried a number of ways (VARIOUS SAME) but I did not succeed! Most give me a UNDEFINED
Follow the code:
PHP:
<?php
require_once('acessabanco.php');
$objDb = new db();
$link = $objDb->conecta_banco();
$sql = "SELECT p.sequencia codigo,
p.nome_completo nome,
c.data_nascimento data,
t.celular_1 celular
FROM pessoas p,
clientes c,
telefones t
WHERE p.sequencia = t.cod_pessoa
AND c.cod_pessoa = p.sequencia";
$exec = mysqli_query($link, $sql);
if ($exec){
while ($clientes = mysqli_fetch_array($exec)){
echo('<tr><td id="sequencia">' . $clientes['codigo'] . '</td>
<td>' . $clientes['nome'] . '</td>
<td>' . $clientes['data'] . '</td>
<td>' . $clientes['celular'] . '</td>
<td><button type="button" id="teste" class="btn btn-primary btn-sm">Small button</button></td>
<td><a type="button" onClick="teste()" class="btn btn-danger btn-sm">Small button</a></td></tr>');
}
}
?>
JQUERY:
$(document).ready(function () {
$('#content').css('display', 'none');
$.ajax({
url: 'php/lista_clientes.php',
type: 'post',
success: function (data) {
$("#carrega_pag").append(data);
}
});
function teste (){
$('table tr').each(function(){
var teste = $(this).closest('td').attr('id');
console.log(teste);
)};
HTML:
<table class="table table-hover">
<thead>
<tr>
<th>Código</th>
<th>Nome Completo</th>
<th>Data de Nascimento</th>
<th>Celular</th>
<th>Opções</th>
</tr>
</thead>
<tbody id ="carrega_pag">
</tbody>
</table>
Can anyone help me? I am very grateful! Well I've been doing this for a long time ... Thank you !!