{hero}

div.id

Since: DataTables 2.1

Set the ID for the created element.

Description

This option is used to set an id on the div element that is created by the div feature. It might typically be used to select the element after initialisation so events can be added or the content dynamically updated.

Example

Add text after initialisation using a selector:

let table = new DataTable('#myTable', {
	layout: {
		top: {
			div: {
				id: 'dynamic'
			}
		}
	}
});

// Wait for the table to be ready - allows this to work with DOM or Ajax loaded data
table.ready(() => {
	let el = document.querySelect('#dynamic');

	el.textContent = 'Dynamically updated';
});

Related

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