我想将文本对齐jquery数据表中第一列的中心。 我有一个CSS,但它不适用于ie8。 除此之外,我还使用fnAddData。 有人能帮我吗?谢谢。
<table id="table1">
<thead>
<th></th><th></th>
<thead>
<tbody>
<tr>
<td>1</td> <td>2</td> </tr> <tr> <td>3</td> <td>4</td>
</tr> </tbody> </table>
$('#table1').dataTable({
"sScrollY": "200px",
"bScrollCollapse": true,
"bPaginate": false,
"bJQueryUI": true,
"aoColumnDefs": [
{ "sWidth": "10%", "aTargets": [ -1 ] }
],
"bLengthChange": false,
"bFilter": true,
"bSort": false,
"bInfo": false,
"bAutoWidth": false
});
$('#table1').dataTable().fnAddData( [
"a","b"],false);
#table1 td:first-child {
text-align: center;
}
答案 0 :(得分:0)
您需要更改:
#table1 td:first-child {
text-align: center;
}
进入
#table1 tr:first-child td {
text-align: center;
}
它将选择表格的第一个tr的td
从IE8开始支持:first-child选择器。它是CSS 2.1标准http://caniuse.com/#feat=css-sel2
的一部分