Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
JQuery Data table can not get value from row

I am trying to get value from row and call a function with onClick

{
                mDataProp: null,
                "sClass": "left",
                "render": function (data, type, row, meta) {
                    console.log("row" + JSON.stringify(row));
                    let el = "";
                    let id = row["id"];
                    let value = row["value"];

                    if(id !== "" && value !== "") {
                        el = "<a title='Delete' onclick='del(" + id + ", " + value + ")'><i class='fas fa-trash'></i></a>"
                        console.log(el);
                    }
                    return el;
                }
            }

Here the console output is ok

row{"id":"abc","value":"111"}
<a title='Delete' onclick='del(abc, 111)'><i class='fas fa-trash'></i></a>

But in the del function the value of id changes

function del(id, value) {
    console.log("delete " + id + value);
    //
}

The output is

delete [object Object]111

Why I can not pass proper value to the function. How do I solve this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

try to change the string quotation to backtick "``"

el = <a title='Delete' onclick='del("${id}", "${value}")'><i class='fas fa-trash'></i></a>

enter image description here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda