{hero}

column().header()

Since: DataTables 1.10

Get the header node for the selected column.

Description

This method can be used to obtain (and therefore modify) the header cell used for a column. This may be a th or td element depending on the HTML for your table.

The cell return is the one used by DataTables for adding the ordering click listener. If you have multiple cells in a header (i.e. multiple rows), which one DataTables uses as the primary header cell is defined by the orderCellsTop option.

Note that if the selector used in column() matches more than one column, the result set will be truncated to a single column - the first one in the result set.

Type

function column().header( [row] )

Description:

Get the header th / td cell for a column.

Parameters:
Returns:

The header cell for the selected column.

Example

Alert the name of the column for a cell that was clicked on:

var table = new DataTable('#myTable');

$('#example tbody').on('click', 'td', function () {
	var idx = table.cell(this).index().column;
	var title = table.column(idx).header();

	alert('Column title clicked on: ' + $(title).html());
});

Related

The following options are directly related and may also be useful in your application development.