Bootstrap表行选择

时间:2016-12-22 18:54:25

标签: javascript jquery css twitter-bootstrap html-table

Example

我似乎无法突出显示整行。无论哪一行是具有sorted_1类的行,当我将其标记为活动时,不会选择所选的突出显示。即使在单元格上进行排序时手动设置背景也不会产生结果。有什么想法吗?

My Code Here

             <table class="table table-bordered table-hover" id="accountTable">
                <thead>
                    <tr>
                        <th style="width: 50%;">Account Name
                        </th>
                        <th style="width: 50%;">Profit Center Number
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Test Acct</td>
                        <td>XXXX99753</td>
                    </tr>
                    <tr>
                        <td>Test Acct 2</td>
                        <td>XXXX99885</td>
                    </tr>
                    <tr>
                        <td>Account 3</td>
                        <td>XXXX99885</td>
                    </tr>
                    <tr>
                        <td>Z Account</td>
                        <td>XXXX99885</td>
                    </tr>
                </tbody>
            </table>

当然,在我的脚本部分末尾调用它。

$('#accountTable').dataTable();

2 个答案:

答案 0 :(得分:1)

table.dataTable td.sorting_1,
table.dataTable td.sorting_2,
table.dataTable td.sorting_3,
table.dataTable th.sorting_1,
table.dataTable th.sorting_2,
table.dataTable th.sorting_3 {
    background: none !important;
}

似乎这就是问题所在。我使用了这些项目中的库存内部样式表,它有这个可爱的部分:/

答案 1 :(得分:0)

td添加样式定义:

.active td {
  background: red !important;
}

您也可以添加此样式

tr:not(.active):hover td {
  background: #e99 !important;
}

<强> jsfiddle