2017-08-04 45 views
0

所以我想添加一個類到我的錶行除了標題,但我不知道如何做到這一點。有人知道我能做到這一點嗎?添加一個類到動態引導錶行

這是我的表:

<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 
}); 
+1

的文檔使用的是bootstrapTable插件,你不覺得,信息peice的是解決有用嗎? – jidexl21

回答

0

1:加入HTML tbody標籤table

2nd: simple add t他類你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> 

jQuery中

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

看看舉表的文檔,並使用該行的樣式屬性, 我不熟悉那個插件,但我覺得它應該LD是這樣

$('#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/