我想要修改由jQuery Datatable插件生成的datatable中的某一列标题。
您知道我是否可以像这样做:
table = $('#example').DataTable({
"data": source_dataTable,
"columnDefs": defs,
"dom": 't<"top"f>rt<"bottom"lpi><"clear">',
});
// WHAT I WANT TO DO:
table.column(0).title.text("new title for the column 0")
它会将HTML的第一行呈现为:
<table id="example" class="row-border hover dataTable no-footer" role="grid" aria-describedby="example_info" style="width: 1140px;">
<thead>
<tr role="row">
<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1" aria-label="S&#233;lectionn&#233;: activer pour trier la colonne par ordre croissant" style="width: 94px;">Sélectionné</th>
<th class="sorting" tabindex="0" aria-controls="example" rowspan="1" colspan="1" aria-label="Anglais : activer pour
trier la colonne par ordre croissant" style="width:
62px;">Anglais </th>
</tr>
</thead>
</table>
在普通表格中,下面的代码可以正常工作,但对于由jQuery插件渲染的datatable,它不起作用:
$('#example tr:eq(0) th:eq(0)').text("Text update by code");
也许有一个API方法或者其他的DOM方式吗?