How to remove td in a table

How to remove td cell in table using MVC4?

Can I use jQuery or javascript? And if so, how?

 <table class="table table-striped table-bordered table-hover" id="tblParticipantList"> <thead> <tr> <th>Name</th> <th>Adress</th> <th>Redeem Code</th> </tr> </thead> <tbody> <tr data-id="columnId" id="customerPartial_94"> <td data-field="NAME">Attn Donna</td> <td data-field="ADDRESS">3046 Lavon Drive Newyork America 7504</td> <td data-field="SECURITY_REDEMPTION_CD"></td> </tr> <tr data-id="columnId" id="customerPartial_95"> <td data-field="NAME">F 1 La 1</td> <td data-field="ADDRESS">Asd 1 s 1 Ci 1 s</td> <td data-field="SECURITY_REDEMPTION_CD"></td> </tr> </tbody> </table> 
+5
source share
2 answers

To remove a TD item, you must know exactly what you want to delete.

  • Delete all TD items

     $('#tblParticipantList > tr > td').remove(); 
  • Delete TD in the specified line

     $('#tblParticipantList > tr').eq(rowNum).children('td').remove(); 
  • Delete TD in the specified rows and columns

     $('#tblParticipantList > tr').eq(rowNum).children('td').eq(colNum).remove(); 
+7
source

Remove the child td position you want using eq() . Use the correct identifier and class in the selector for the expected result.

 $('.table-striped tr').each(function(){ $(this).children('td').eq(3).remove(); }); 
+3
source

All Articles