How to suppress table headers completely in jQuery

2020-02-03 05:42发布

I am using the DataTables plugin (www.datatables.net) for jQuery to display tables on a web page.

After reading through the documentation and doing some searches, I am unable to find out how to completely suppress or hide table headers, using the DataTables options or API.

4条回答
We Are One
2楼-- · 2020-02-03 06:13

Simple add the style display:none inline style to your thead tag.

    <thead style="display:none;">
    </thead>
查看更多
淡お忘
3楼-- · 2020-02-03 06:18

Just add this to your css:

thead {
  display:none;
}
查看更多
▲ chillily
4楼-- · 2020-02-03 06:23

I know the question is pretty old, but I searched for it today and found another solution ...

In your js / coffee file:

$("#selector").dataTable({
  ... your other options ...

  fnDrawCallback: -> $("#selector thead").remove()
})

Pure JS variant:

$("#selector").dataTable({
  ... your other options ...

  fnDrawCallback: function() {
    $("#selector thead").remove();
  }
});
查看更多
再贱就再见
5楼-- · 2020-02-03 06:25

Why don't you simply hide them through css (i think datatables requires a thead section to work)?

.dataTables_wrapper table thead{
    display:none;
}

fiddle here: http://jsfiddle.net/LhZF3/

查看更多
登录 后发表回答