Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 向动态引导表行添加类_Javascript_Jquery_Html_Twitter Bootstrap_Bootstrap 4 - Fatal编程技术网

Javascript 向动态引导表行添加类

Javascript 向动态引导表行添加类,javascript,jquery,html,twitter-bootstrap,bootstrap-4,Javascript,Jquery,Html,Twitter Bootstrap,Bootstrap 4,因此,我想在表行中添加一个类,但不知道如何添加。有人知道我怎么做吗 这是我的桌子: <table id="table" class="hidden table table-bordered table-striped table-hover"> <thead> <tr> <th data-field="variant">Variant</th> <th dat

因此,我想在表行中添加一个类,但不知道如何添加。有人知道我怎么做吗

这是我的桌子:

<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>

1st:在html
表格中添加
tbody
标记

2nd:simple为您添加类
tbody tr
仅此而已

$('#table tbody tr').addClass("newclass");
HTML:

<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>
    <tbody>  //tbody added here  
        <tr>
        ....
        </tr>
    </tbody>
</table>

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

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

阅读此处的文档

您正在使用bootstrapTable插件,您不认为大量信息对解决此问题有用吗?
$('#table tbody tr').addClass("newclass");
$('#table').bootstrapTable({
    data: returnValue, 
    rowStyle :  function(row, index) {
     return {
     classes: 'text-nowrap another-class',
     css: {"color": "blue", "font-size": "50px"}
     };
 }
});