3
I made a noose .each
that returns some button
:
$(document).ready(function(){
listarPedidos()
var consultas = setInterval(listarPedidos, 4000);
});
function listarPedidos(){
$.getJSON('conectar/_pedidos/listaPedidos.php', function (data) {
$.each(data, function(i, valor){
elementoFILA += "<tr id='statusFILA'>";
elementoFILA += "<td>" + valor.PED_ID + "</td>";
elementoFILA += "<td>" + valor.PED_DATA_N + "</td>";
elementoFILA += "<td>" + resultado + " / " + valor.CLI_TEL + "</td>";
elementoFILA += "<button class='btn btn-info' id='btnVisu' title='Visualizar Pedido'><i class='fas fa-eye'></i> </button>";
elementoFILA += "<button class='btn btn-primary' title='Editar Pedido'><i class='fa fa-pencil-alt'></i> </button>";
elementoFILA += "<button class='btn btn-dark' disabled='' title='Setar Saiu Entrega'><i class='fa fa-motorcycle'></i> </button>";
elementoFILA += "<button class='btn btn-dark' id='btnFinalizar' disabled='' title='Finalizar Pedido'><i class='fa fa-check'></i> </button>";
elementoFILA += '</div></td>'
elementoFILA += "</tr>";
}
My difficulty is picking up line id='btnVisu'
.
I’m trying to do it this way, but not the right way:
$('#btnVisu').click(function () {
alert("clicou");
});
I know you have to pick up the accountant’s .each
but I couldn’t do.
Your loop is generating several elements with the same
id
. Hence, the.click
will be applied only to the first#btnVisu
... You had a question almost identical to yours these days. I’ll see if I find it and Linko here.– LipESprY