javascript - 将类添加到动态 Bootstrap 表行

标签 javascript jquery html twitter-bootstrap bootstrap-4

所以我想在表行中添加一个类(标题除外),但我不知道该怎么做。有人知道我该怎么做吗?

这是我的 table :

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

这是当前我添加数据并希望将类添加到行的位置

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

最佳答案

查看 Bootstrap 表文档并使用行样式属性, 我不熟悉那个插件,但我想它应该是这样的

$('#table').bootstrapTable({
    data: returnValue, 
    rowStyle :  function(row, index) {
     return {
     classes: 'text-nowrap another-class',
     css: {"color": "blue", "font-size": "50px"}
     };
 }
});

在此处阅读文档 http://bootstrap-table.wenzhixin.net.cn/documentation/

关于javascript - 将类添加到动态 Bootstrap 表行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45499723/

相关文章:

javascript - 将 div 链接到路由 meteor (Iron Router)

javascript - 调整窗口大小时,如何在不进行水平和垂直拉伸(stretch)的情况下使图像变大?

javascript - 多个覆盖 'keyup' 事件

HTML 布局调试

javascript - Canvas 鼠标指针未同步

javascript - div 中仅附加了一个 <br> 元素

javascript - jQuery:val() 是否足够快以重复使用,还是将值放在变量中更好

php - PHP表单未插入MySQL数据库

Javascript 提取处理 json 和 blob

javascript - Safari 上页面加载时固定标题下的内容 "slides"损坏