The following is working for me:
$('#datatable').on('page.dt', function() {
alert("changed");
});
Whenever I am changing the page,the alert is shown.But if I want to alert the page no. which is clicked then what's the way
table.page.info()
returns the current pagination information. That is current page
, number of pages
, recordsDisplay
, recordsTotal
and more.
var table = $('#datatable').DataTable();
$('#datatable').on('page.dt', function() {
var info = table.page.info();
var page = info.page+1;
alert('changed - page '+page+' out of '+info.pages+' is clicked');
});
see demo -> http://jsfiddle.net/qpLtLfaz/
来源:https://stackoverflow.com/questions/25305749/alert-the-page-no-on-jquery-datatables-page-change-event