jQuery,清除/清空tbody元素的所有内容? [英] Jquery, Clear / Empty all contents of tbody element?
问题描述
我以为这很简单,但是空方法似乎无法清除我的肢体.如果有人知道执行此操作的正确方法,我将不胜感激,我只想删除tbody中包含的所有内容.到目前为止,我正在尝试:
I thought this would be rather simple but it seems the empty method is not working to clear out a tbody that I have. I would appreciate if anyone knows a proper way to do this, I just want to delete everything contained within the tbody. So far I am trying:
$("#tbodyid").empty();
HTML:
<table>
<tbody id="tbodyid">
<tr><td>something</td></tr>
</tbody>
</table>
注意:我正在尝试将其与其他人编写的,用于项目的插件集成在一起.我正在服务器端生成新的<tr><td>new data</td></tr>
,并且希望能够擦除现有表行并将其替换为AJAX回调.
NOTE: I am trying to do this to integrate with a plugin written by someone else that I am being made to use for a project. I am generating new <tr><td>new data</td></tr>
server-side and want to just be able to wipe out the existing table rows and replace them on AJAX callbacks.
推荐答案
jQuery:
$("#tbodyid").empty();
HTML:
<table>
<tbody id="tbodyid">
<tr>
<td>something</td>
</tr>
</tbody>
</table>
为我工作
http://jsfiddle.net/mbsh3/
这篇关于jQuery,清除/清空tbody元素的所有内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!