JQuery, Clear / Clear all contents of tbody element?

I thought it would be pretty simple, but it seems that an empty method does not work to clear yours which I have. I would appreciate if anyone knows the right way to do this, I just want to remove everything in the body. While I'm trying:

$("#tbodyid").empty(); 

HTML:

 <table> <tbody id="tbodyid"> <tr><td>something</td></tr> </tbody> </table> 

NOTE. I am trying to do this in order to integrate with a plugin written by someone else that I use for a project. I am creating a new server side <tr><td>new data</td></tr> and I just want to erase the existing table rows and replace them with AJAX callbacks.

+44
javascript jquery html
Feb 13 2018-11-11T00:
source share
3 answers

JQuery

 $("#tbodyid").empty(); 

HTML:

 <table> <tbody id="tbodyid"> <tr><td>something</td></tr> </tbody> </table> 

Works for me
http://jsfiddle.net/mbsh3/

+75
Feb 13 '11 at 6:45
source share

You probably already figured this out, but for someone stuck in this problem:

 $("#tableId > tbody").html(""); 
+41
May 08 '13 at 15:36
source share
  <table id="table_id" class="table table-hover"> <thead> <tr> ... ... </tr> </thead> </table> 

use this command to clear the body of this table: $("#table_id tbody").empty()

I use jquery to dynamically load the contents of a table and use this command to clear the body when updating.

Hope this helps you.

+1
May 27 '16 at 10:48
source share



All Articles