{hero}

caption()

Since: DataTables 2.0

Get / set the table's caption.

Description

HTML tables have an optional element called caption which can be used to show the title of a table to the end user. This can greatly enhance accessibility since it can give a summary of the contents of the table without the end user needing to read the surrounding text.

This method is provides to control the contents of a DataTables' caption element.

Types

function caption()

Description:

Get the contents of the caption element for the table.

Note that if the API instance references multiple tables, only the first table in the collection will be considered for the getter.

Returns:

Contents of the caption element. Will be null if there is no caption.

function caption( set [, side ] )

Description:

Set the contents of the caption element. If the table doesn't have a caption element, one will be created automatically.

Note that is the API instance references multiples tables, the caption will be set for all tables referenced.

Parameters:
Returns:

DataTables API instance for chaining.

Examples

Set the table's caption:

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

table.caption('Table 1: Class averages');

Set the table's caption and display at the bottom of the table:

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

table.caption('Table 2: Year averages', 'bottom');

Related

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