【问题标题】:Check dynamic Bootstrap Table for class检查类的动态引导表
【发布时间】:2017-08-04 10:02:42
【问题描述】:

所以我得到了这张桌子

<table id="table" class="table table-bordered table-hover">
    <thead>
        <tr>
            <th data-field="id" class="hidden">ID</th>
            <th data-field="variant">Variant</th>
            <th data-field="description">Description</th>
        </tr>
    </thead>
    <tbody>
    </tbody>
</table>

它将被数据槽填满

$('#table').bootstrapTable({
    data: returnValue
});

然后我可以单击将向其添加类 .bg-info 的行,我想检查一行是否具有该类,然后将行数据保存在 var

这是我的尝试:

var item = $.map(table.rows('.bg-info').data(), function (item) {
    return item[0]
});

但是 table.rows 显然不能用作方法

【问题讨论】:

  • 表中的内容及其定义方式

标签: javascript jquery html twitter-bootstrap bootstrap-4


【解决方案1】:

如果您想选择表中所有类bg-info 的行。使用基于该类的 jQuery 选择器:

var bgInfoRows = $("#table tbody .bg-info");

您将拥有 tbody 中具有 bg-info 类的每个项目。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-31
    • 1970-01-01
    • 1970-01-01
    • 2015-04-09
    • 1970-01-01
    • 1970-01-01
    • 2011-07-02
    • 1970-01-01
    相关资源
    最近更新 更多