提醒页面否。在jQuery dataTables页面更改事件 [英] Alert the page no. on jQuery dataTables page change event

查看:137
本文介绍了提醒页面否。在jQuery dataTables页面更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下内容适用于我:

$('#datatable').on('page.dt', function() {
    alert("changed");
});

每当我更改页面时,都会显示警报。但是如果我想提醒页面no 。这是点击的方式

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()返回当前分页信息。这是当前页面页数 recordsDisplay recordsTotal 等等。

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');
});

查看演示 - > http://jsfiddle.net/qpLtLfaz/

see demo -> http://jsfiddle.net/qpLtLfaz/

这篇关于提醒页面否。在jQuery dataTables页面更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆