caption()
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
caption()
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:
string
Contents of the caption element. Will be null
if there is no caption.
caption( set [, side ] )
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:
Name | Type | Optional | |
---|---|---|---|
1 | set | No | |
The value to show in the table's | |||
2 | side | Yes | |
Typically the position of the It can be given |
Returns:
DataTable.Api
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.