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"}
};
}
});