javascript - 如何删除 footable 中的所有行?

标签 javascript jquery footable

我有一个脚垫需要清洁。我的意思是,我需要删除 footable 中的所有行。是否有任何功能可以做到这一点?还是需要逐行删除?

我尝试重新初始化表:

$('.footable').footable();

我也试过像这样在行之间迭代:

var footable = $('table').data('footable');

//This is the problem I don´t know how to get first row in the table.
var row = ??????.parents('tr:first'); 

var next=row.next();
for (var i=0; i<long-1; i++){
  footable.removeRow(next);
  next=row.next();
}
footable.removeRow(row);

还有我对应的html源码:

<table class="footable footable-loaded">
<thead>
<tr>
    <th>Cantidad</th>
    <th>Producto</th>
    <th>Precio</th>
    <th>Eliminar</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
    <tr>
        <th></th>
        <th>Total</th>
        <th id="total">19.5</th>
        <th></th>
    </tr>
</tfoot>
</table>

最佳答案

可以通过removeRows()函数删除:

function removeRows(){
    $(".footable>tbody>tr").each(function(index, elem){
        $(elem).remove();
     });
}

DEMO

关于javascript - 如何删除 footable 中的所有行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25807324/

相关文章:

javascript - 根据另一个 div 滚动位置显示 div

css - Footable css 类添加逗号

javascript - Meteor 0.8 Blaze 如何更新 Jquery 插件的渲染变化

javascript - FooTable 插件日期时间问题

javascript - 发布前的 ajax 条件变量

javascript - 如果 WordPress 评论日期低于 2014 年 4 月,如何显示 p 标签?

javascript - 设置溢出-y : hidden; causes the page to jump to the top in Firefox

javascript - 设置innerHTML字符串会产生语法错误

javascript - jQuery 在找到特定文本字符串时添加属性

jquery - 如何在 Typescript Angular Controller 中使用 document ready