我试图确保Twitter Bootstraptable-stripped
CSS样式应用于在运行时动态添加行的表格。出于某种原因,我试图深入到底,我无法得到这种特定的风格,因此我的新行的样式与剥离的外观。动态创建表格行后应用Bootstrap“表格条纹”
所以,如果我有这样的HTML与table-stripped
包括:
<table class="table table-bordered table-striped table-condensed table-hover" id="table2">
<thead>
<tr>
<th>Heading A</th>
<th>Heading B</th>
<th>Heading C</th>
</tr>
</thead>
<tbody></tbody>
</table>
然后我运行这段JavaScript代码:
for (var i = 0; i < 5; i++)
{
$('#table2 > tbody:last').before('<tr><td>' + i +'</td><td>b</td><td>c</td>');
}
我会得到我的5个新行,但他们不会有table-stripped
风格应用。
即使我在创建后使用这个手动添加类,它没有区别。
$('#table2').addClass('table-hover');
我已经创建了一个jsFiddle sample所以你可以看到这个运行。
感谢@MrCode的贡献。 – Bern