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

271
Views
¿Cómo eliminar dos filas "tr" con js?

Cuando elimino un producto en la cesta, los productos se eliminaron correctamente pero el nombre de la empresa no se elimina. Estoy usando javascript. No puedo resolver el problema, ayúdenme por favor...

ingrese la descripción de la imagen aquí

 function getCurrentRow(t) { var v = parseInt($.trim(t.attr("data-row-id"))); if (isNaN(v)) { console.log("data-row-id:null"); return null; } var currentRow = getRow(v); if (currentRow == null) { console.log("currentRow:null"); return null; } return currentRow; } // Delete basketContainer.on('click', 'button[data-button-name="delete"]', function() { var o = $(this); var t = o.closest("tr"); var currentRow = getCurrentRow(t); if (currentRow == null) { return; } postData(t, currentRow.index, { "basketid": currentRow.id, "pdoductid": currentRow.ProductID, "count": 0, "cmdtype": cmdTypes.Delete }); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <table> <thead> <tr data-row-id="item.id"> <td colspan="4" style="color: #d53434">Shop: <strong>Shop name</strong></td> </tr> </thead> <tbody> <tr role="row" data-row-id="item2.id"> ... </tr> </tbody> </table>

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

0

¿Te refieres a quitar la mesa cuando no haya más productos de esa tienda?

 $("#basketContainer").on('click', 'button[data-button-name="delete"]', function() { const $tr = $(this).closest("tr"); const $tb = $(this).closest("tbody"); $tr.remove() if ($tb.find("tr").length === 0) $tb.closest("table").remove() });
 table { border: 1px solid black }
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <div id="basketContainer"> <table> <thead> <tr data-row-id="item.id"> <td colspan="4" style="color: #d53434">Shop: <strong>Shop name 1</strong></td> </tr> </thead> <tbody> <tr role="row" data-row-id="item2.id"> <td><button type="button" data-button-name="delete">Delete</button></td> </tr> <tr role="row" data-row-id="item2.id"> <td><button type="button" data-button-name="delete">Delete</button></td> </tr> </tbody> </table> <table> <thead> <tr data-row-id="item.id"> <td colspan="4" style="color: #d53434">Shop: <strong>Shop name 2</strong></td> </tr> </thead> <tbody> <tr role="row" data-row-id="item2.id"> <td><button type="button" data-button-name="delete">Delete</button></td> </tr> <tr role="row" data-row-id="item2.id"> <td><button type="button" data-button-name="delete">Delete</button></td> </tr> </tbody> </table> </div>

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!