Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda