bootstrap -table隐藏除了单击的行之外的所有行

时间:2016-06-27 20:11:26

标签: javascript jquery

var $table = $('#table');
$table.on('expand-row.bs.table', function (e, index, row, $detail) {
    $detail.html('Carregando os dados...');
});

我想捕获除点击的行以外的所有行,然后关闭它们。

1 个答案:

答案 0 :(得分:0)

我认为expand-row是一个班级...
我还假设您行的实际display值为table-row ...
但它也可能是inline

试试这个:

var $table = $('#table');
$table.on("click", '.expand-row.bs.table', function (e, index, row, $detail) {

    $('.expand-row.bs.table').each(function(){  // iterates all rows.
        $(this).css({"display":"none"});        // Here, "this" is row element.
    });

    $(this).css({"display":"table-row"});   // Here, "this" is the clicked element.

    $detail.html('Loading data ...');
});