1
Without too much hustle, I’m stuck on the following problem:
I have the following JS code:
data.forEach(function(item) {
$("#bodyTabelaClientes").append(
"<tr><td style = 'text-align: center'>" + item.nome
+ "</td> <td style = 'text-align: center'> " + item.telefone
+ "</td> <td style = 'text-align: center'> " + item.cep
+ "</td> <td style = 'text-align: center'>" + item.endereco
+ "</td> <td style = 'text-align: center'><button class = 'btn btn-success btnSelecionarCliente' onclick='selecionarCliente("+item+")'>Selecionar</button></tr>");
});
My problem is the button inside the append, I need to pass this parameter 'item' as parameter to another function, to take the data of this item and do something with them, however, when clicking, the console accuses
Uncaught Syntaxerror: Unexpected Identifier
with a blank page. I believe it’s a mistake with the quotes, but I couldn’t identify it, does anyone have any idea what to do? Thank you!
It paid off, it worked perfectly and the explanation in the end also made a difference. Thank you.
– Gabriel Augusto