Native JavaScript pagination plugin, customizable (original work)

Add-ons
2026-07-21 13:24 5 次浏览 • 0 次下载 3.6KB
Native JavaScript pagination plugin, customizable (original work)

Last Updated: 2020-12-08 21:02:09

Changelog:Fixed a bug where clicking the Home and Last buttons had no effect when the total number of pages changed.


Last Updated: 2020-12-07 15:16:26

Changelog:After clicking, you can reset the total number of pages or the overall number of data items.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var nums = 150, // Total count
counts = 10; // Items per page
var p = new Page({
el: '#test',
nums: nums,
counts: counts,
defaultPage: 1,
defaultPage: 1,
showHeadFoot: !false, // Show Home and Last buttons
jumpToOrder: true, // Navigate to a specified page
showNowAndAll: true, // Current page / Total pages
clickEvent: function(currectPage, _this) {
console.log('Click' + currectPage + 'Page');
// console.log(p == _this); // true
// _this.pages = 20; //p.pages = 20; Reset the total number of pages
_this.nums = 300; // p.nums = 300; Reset the total number of data items. Choose either this option or setting the total number of pages.
}
});

Last Updated: 2020-09-18 01:10:33

Changelog:

1. Added navigation to a specified page.

2. Added display of the current page and total number of pages.

3. All styles can be customized.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var nums = 400, // Total count
counts = 10; // Items per page
var p = new Page({
el: '#test',
nums: nums,
counts: counts,
defaultPage: 1, // Default page
showHeadFoot: !false, // Show Home and Last buttons. Text can be customized: head: Home, foot: Last
jumpToOrder: true, // Navigate to a specified page. Newly added.
showNowAndAll: true, // Current page / Total pages. Newly added.
clickEvent: function(currectPage) {
// alert('Clicked page ' + currectPage);
// console.log('Clicked page ' + currectPage);
}
});

Last Updated: 2020-09-16 23:18:58

Usage

Required Files

1
2
<link rel="stylesheet" type="text/css" href="./css/index.css" />
<script src="./js/index.js" type="text/javascript" charset="utf-8"></script>

html

1
<div id='test'></div>

js

1
2
3
4
5
6
7
8
9
10
11
12
13
var nums = 200, // Total number of data items
ounts = 10; // Items per page. This configuration results in 20 pages.
var p = new Page({
el: '#test', //Controls
nums: nums, // Total number of data items
counts: counts, // Items per page
defaultPage: 6, // Default page number
showHeadFoot: !false, // Show Home and Last buttons
clickEvent: function(currectPage) {
// currectPage is the clicked page number; this callback function defines what happens when a page is clicked
// console.log('Clicked page ' + currectPage);
}
});
星河码客

发现和分享优质开源项目,传承互联网精神,为开发者服务。

关于本站

联系我们

微信/广告合作:ITcloub (备注星河码客)

免责声明:本站资源版权归原作者所有,仅供学习与交流。如有侵权,请通过「关于我们 - 侵权投诉」联系删除。

Powered by Nuxt · Deployed on Cloudflare