Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
¿Cómo vincular una URL dinámica a la etiqueta <td> en jquery?

Tengo una fila secundaria en la fila de la tabla de datos, y estoy tratando de agregar un enlace dinámico al encabezado de esa fila de la nube, por enlace dinámico quiero decir que la URL dependerá del valor de la celda

Por ejemplo: digamos que la URL es http://example.com/delete.php y el valor de d[0] es 123456789 , entonces quiero agregarlo a la URL para que la URL completa sea algo así como http://example.com/delete.php?account=123456789 y vincúlelo al texto Delete Account

 function format(d){ // `d` is the original data object for the row return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">' + '<tr>' + '<td>Active Indicators:</td>' + '<td>' + d[5] + '</td>' + '</tr>'+ '<tr>' + '<td>Delete Account</td>' + '<td>' + d[0] + '</td>' + '</tr>' '</table>'; }

¿Es posible hacer algo como esto? si es así, ¿cómo se hace?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Considera lo siguiente.

 function makeTable(tableData, target) { var table = $("<table>", { cellspacing: 0, border: 0, id: "myData" }).css("padding-left", "50px"); var row; $.each(tableData, function(k, v) { row = $("<tr>", { "data-id": v.accountId }).appendTo(table); $("<td>").html("Active Indicators:").appendTo(row); $("<td>").html(v.indicators).appendTo(row); $("<td>", { class: "remove" }).html("Delete").appendTo(row); }); if (target != undefined) { table.appendTo(target); } return table; } makeTable(d, $("#results")); $(".remove").on("click", function(event) { var row = $(this).closest("tr"); $.get("http://example.com/delete.php", { account: row.data("id") }, function(result) { alert("Account " + row.data("id") + " Deleted"); row.remove(); }); });

Es posible que deba ajustar los datos de su tabla. No proporcionó un ejemplo de sus datos, por lo que no estoy seguro de cómo está formateado.

 [{ accountId: 1001, accountName: "First American Trust", indicators: "End" }];
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!