How to get name of datatable column?

后端 未结 5 1514
春和景丽
春和景丽 2021-02-18 16:25

I\'m using DataTable 1.10.9 (from https://datatables.net). Columns for the datatable are defined at the initialization step in javascript and each column has a unique name, e.g.

5条回答
  •  没有蜡笔的小新
    2021-02-18 16:36

    below code worked for me

    this.api().columns().every(function() {
      console.log( this.header().textContent )
    })
    

    also you can add a specific html class for only specific column names like having that class

    this.api().columns(".myColumnClass").every(function() {
      console.log( this.header().textContent )
    })
    

提交回复
热议问题