简单通用 jQuery分页插件 Simple Pagination.js

  • 源码大小:11.17KB
  • 所需积分:1积分
  • 源码编号:19JP-3342
  • 浏览次数:645次
  • 最后更新:2023年06月03日
  • 所属栏目:其他
本站默认解压密码:19jp.com 或 19jp_com

简介

分页是任何网页上最常用和最基本的功能之一。它为用户提供了一种在大型数据集中导航的方式。

本页将介绍一个全新的jQuery分页插件,它可以无缝地添加到列表、表、div和许多其他类型的HTML元素中。

更多功能:

  • 分页样式可以使用CSS进行完全自定义,以适合您的设计风格。
  • 每页要显示的自定义项目数。
  • 自定义可见页面数。
  • 您可以控制每个分页控件的可见性。
  • 多种语言。
  • 还有更多。

参见:

  • JavaScript中的10个最佳分页组件

如何使用它:

1.加载所需的jquery-示例分页-插件.jsjQuery之后的脚本。

  1. <script src="/path/to/cdn/jquery.slim.min.js"></script>
  2. <script src="/path/to/jquery-simple-pagination-plugin.js"></script>

2.在包含大量需要分页的元素的容器上初始化插件。

  1. <div id="container">
  2. <table>
  3. <tbody>
  4. <tr><td>One</td></tr>
  5. <tr><td>Two</td></tr>
  6. <tr><td>Three</td></tr>
  7. ...
  8. </tbody>
  9. </table>
  10. </div>
  1. $('#container').simplePagination();

3.默认情况下,此插件将自动应用于大型HTML表。您可以通过修改分页_容器参数

  1. $('#container').simplePagination({
  2. pagination_container: 'li',
  3. });

4.指定每页要显示的项目数。默认值:25。

  1. $('#container').simplePagination({
  2. items_per_page: 25,
  3. });

5.将您自己的样式应用于分页链接和控件。

  1. .simple-pagination-page-x-of-x {
  2. ...
  3. }
  4.  
  5. simple-pagination-showing-x-of-x {
  6. ...
  7. }
  8.  
  9. simple-pagination-items-per-page {
  10. ...
  11. }
  12.  
  13. simple-pagination-select-specific-page {
  14. ...
  15. }
  16.  
  17. simple-pagination-page-numbers a {
  18. ...
  19. }

6.所有默认插件选项。初始化插件时,可以通过将对象文字传递给简单分页()方法

  1. $('#container').simplePagination({
  2.  
  3. pagination_container: 'tbody',
  4. html_prefix: 'simple-pagination',
  5.  
  6. // button, span, div, et cetera
  7. navigation_element: 'a',
  8. items_per_page: 25,
  9. number_of_visible_page_numbers: 5,
  10.  
  11. // enable/disable controls here
  12. use_page_numbers: true,
  13. use_first: true,
  14. use_previous: true,
  15. use_next: true,
  16. use_last: true,
  17. use_page_x_of_x: true,
  18. use_page_count: false,
  19. use_showing_x_of_x: true,
  20. use_item_count: false,
  21. use_items_per_page: true,
  22. use_specific_page_list: true,
  23.  
  24. // localize the pagination control
  25. first_content: 'First',
  26. previous_content: 'Previous',
  27. next_content: 'Next',
  28. last_content: 'Last',
  29. page_x_of_x_content: 'Page',
  30. showing_x_of_x_content: 'Showing',
  31.  
  32. items_per_page_content: {
  33. 'Five': 5,
  34. 'Ten': 10,
  35. 'Twenty-five': 25,
  36. 'Fifty': 50,
  37. 'One hundred': 100
  38. },
  39.  
  40. thousands_separator: ','
  41. });

预览截图