Hello, this is bootpag

dynamic pagination jQuery plugin
works well with Bootstrap or standalone

Installation

Package available on npm

npm install bootpag

Getting started

Include plugin script in your html page

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/bootpag@5.0.0/dist/jquery.bootpag.min.js"></script>

Then prepare empty html element which should contain pagination ( bootpag will create pagination list).
After page load init bootpag with number of total pages $('.my-element').bootpag({total: 15}) .
From now on you can listen for page changes $('.my-element').on("page", function(event, num){});

<!doctype html> <html> <head> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootpag@5.0.0/dist/jquery.bootpag.min.js"></script> </head> <body> <div id="content">Dynamic Content goes here</div> <div id="page-selection">Pagination goes here</div> <script> // init bootpag $('#page-selection').bootpag({ total: 10 }).on("page", function(event, /* page number here */ num){ // load content from server here and update DOM, for now just some text $("#content").html("Dynamic content loaded for page " + num); }); </script> </body> </html>

Documentation

Parameters $(element).bootpag({...})

Events available on bootpag object

Simple example

Dynamic content here.

$('.demo1').bootpag({ total: 5 }).on("page", function(event, num){ $(".content").html("Page " + num); // or some ajax content loading... // ... after content load -> change total to 10 $(this).bootpag({total: 10, maxVisible: 10}); });

Advanced example

Dynamic content here.

$('.demo2').bootpag({ total: 23, page: 3, maxVisible: 10 }).on('page', function(event, num){ $(".content2").html("Page " + num); // or some ajax content loading... });

Pro example

Dynamic content here.

$('.demo3').bootpag({ total: 9, page: 5, maxVisible: 6, href: "#pro-page-{{number}}", leaps: false, next: 'next', prev: null }).on('page', function(event, num){ $(".content3").html("Page " + num); // or some ajax content loading... });

Full example

Dynamic content here.

$('.demo4_top,.demo4_bottom').bootpag({ total: 50, page: 2, maxVisible: 5, leaps: true, firstLastUse: true, first: '<span aria-hidden="true">&larr;</span>', last: '<span aria-hidden="true">&rarr;</span>', wrapClass: 'pagination', activeClass: 'active', disabledClass: 'disabled', nextClass: 'next', prevClass: 'prev', lastClass: 'last', firstClass: 'first' }).on("page", function(event, num){ $(".content4").html("Page " + num); // or some ajax content loading... });