Я хочу извлечь идентификатор таблицы из таблицы данных без указания имени таблицы в функции. Например: вместо указания var tableName = $ ('# myTable'). Attr ('name') Я хочу получить имя таблицы без записи # myTable
$(document).ready(function() {
$('#myTable').DataTable( {
dom: 'Bfrtip',
buttons: [
{ extend : 'collection',
text : '<i class="fa fa-bars">buttons</i>',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print',
{
text: 'Report Issue',
action: function ( e, dt, node, config ) {
reportIssue(e, dt, node, config);
}
}
]
}]
} );
// e - the button click event
// dt - the datatable object
// node - button node
// config - the button's config (e.g. 'text')
function reportIssue(e, dt, node, config) {
var tableName = $('#myTable').attr('name');
alert( 'The "' + config.text + '" button was clicked\n'
+ 'for the "' + tableName + '" table.' );
}
});