Downloaded more than 2000 times.
After using various jQuery plugins for pagination, I decided to write my own jQuery paginator plugin. While creating this plugin, I tried to overcome other plugin’s limitations and make it easy & highly customizable to meet demands of most of developers. Here are few features of this plugin,
1) Very simple. Just 1 line of code to apply pagination on any div/container.
2) No need for creating extra divs for pagination.
3) 4 styles of pagination.
4) Various other options like jump to page, page info and change items per page on fly.
5) Easy customization and styling.
6) Nice fading effect during changing of page.
Why use it? Often you have large number of items/data in a div, which not only breaks your design but also looks ugly and lengthy. Apply this plugin on that div and you will get a nice seamless pagination on that div, which don’t break your design and visitors can easily navigate to all the items. You can style or it customize according to your requirements. See Demo.
Implementation:
1) Download latest jquery script and paginator.js
2) Include both scripts in html document in head section.
<script src="js/jquery.js"></script>
<script src="js/paginator.js"></script>
3) Initiate pagination by writing following code in head section inside <script> tags,
<script>
$(function(){ $("#<id_of_div>").pagination(); });
</script>
// instead of <id_of_div>, type in id of the div on which you want to create pagination.
Its all you need to do. Load the page on browser and now you can see a simple, basic pagination on the page. See Demo.
Customization:
1) Style Paginator: There are 3 classes – paginator (container for paginator), active (class for active pages) and inactive (class for current page). We can apply little css on these classes to make paginator looks pretty, either in document itself or in stylesheet. See demo
<style type="text/css">
.active
{
color:#0033CC;
border: solid 1px #0000FF;
padding:3px 5px;
margin:5px;
text-decoration:none;
}
.inactive
{
color:#000000;
cursor:default;
text-decoration:none;
border: solid 1px #0000FF;
background-color:#0099FF;
padding:3px 5px;
margin:5px;
}
</style>
2) Paginator Style: Open paginator.js, there is a variable called paginatorStyle. This variable accepts values from 1 to 4, for displaying different styles of paginator. More info is given in comments below that.
3) Pagination Position: By default the position of paginator is below the div where pagination is applied. In paginator.js you can change paginatorPosition to ‘top’ if you want paginator to be on the top instead of bottom, or ‘both’ if you want it to be on both (top and bottom).
4) Changing Symbols: Open paginator.js, there are variables like firstPageSymbol, previousPageSymbol, nextPageSymbol, lastPageSymbol. You can change these symbols, so instead of << as symbol for first page, you can write FIRST PAGE, or give img tag if you want fancy image for first page. Also, there is a variable called separator, which will appear in-between page options. Make it blank if you don’t want it.
5) Changing Items per page and Start Page: By default there are 5 items per page and start page for pagination is first page. You can change them in paginator.js, the variables are named itemsPerPage and startPage.
6) Enabling other options: There are 3 options available, like goto to page, change items per page, display page info. By default these are disabled, you can enable them according to your needs. You can enable them by replacing false with true as variables value, in paginator.js. More info is given in comments besides each option.
7) Calling pagination again after changing content: If you change content, upon which pagination is applied in-between, just call initPaginator(); after changing content. It will apply pagination again on the new content with same previous settings.
8) De-paginating Content : At any time, if you want to remove pagination from the content, just call $("#<id_of_div>").depagination(); You can call $("#<id_of_div>").pagination(); to apply pagination again on same or any other content. Kindly remember, at one time you can apply pagination on only one div or content. If you want to apply pagination on other div during program, first call depagination function on previous div and then pagination function on new div.
9) Don’t want to open paginator.js: No worries, if you don’t want to change these variables in paginator.js, you can still change these variables in html documents just before calling the pagination function. Like See Demo.
$(function(){
itemsPerPage = 3;
paginatorStyle = 2;
paginatorPosition = 'both';
enableGoToPage = true;
$("#result").pagination();
});
That’s it. Apply it wherever you want. Play around it with, try different styles and options. Email me in case of any bug, error, confusion or you need any further assistance/customization. All kinds of feedbacks are appreciated and welcomed.
I also recently uploaded uncompressed version of the plugin for development purposes, download it. feel free to download and extend it. Also, I have uploaded this plugin on jquery plugin directory. Here is the link – http://plugins.jquery.com/project/jquery-pagination

Tested in all major Browsers

@Mortal thanks. I am working on the next version of the plugin and surely keep your points in mind.
@Davendra Sry buddy but this plugin currently do not support multiple pagination in one page. Wait for next version or try different plugin.
@Charlie Thanks & glad you guys love it so much.
hi Rohit,
firstly thanks for your plugin, it works very nicely and very easy to get going. I only had one problem with it. Due to circumstances beyond my control, some pages on my site load prototype, which means all my jquery stuff has to be done like this:
jQuery.noConflict();
jQuery(document).ready(function($){
$(‘#searchresultset’).pagination();
}
in these circumstances your plugin did not work. $ is not a function. I got hold of the uncompressed version and changed all the $() to jQuery() and it worked fine. For some reason if I do the same replacement in the minimised version, it still does not work.
This is not a huge problem, I will just use the uncompressed version for now, it’s not like I am google needing to save every spare byte.
But I think perhaps it would be best if, *inside* your plugin, it used jQuery() instead of $(), so that it kept working even if some people are using noconflict mode? Or perhaps I don’t understand the issue properly, but however you do it, it would be great if it could work with noconflict.
Anyway this is not to sound ungrateful or demanding, just a suggestion. Thanks again for your work on this!
Thanks for your script. It’s pretty good! I have only one thing to say: it’s good practice not to use reserved words (like active) to define classes in css. I wish you much success!
This looks great however, I have an ajax type search result set I would like to paginate. My result set contains a div per result set with a markup inside each of these divs. It appears that your script is unable to handle such a result set at first glance. Your example merely uses, multiple ‘s but appears to not work if there is a lot of markup… am I missing something simple here?
hey Chris, Can I have a look at your code? I am not sure if I understand your issue well.
hi, is there a possibility to use it with json data and multiple instances in one site?
can we use this in logic iterator for dynamic data
@Sachin yes , you can. you have to call pagination() after your pulling data dynamically.
Excellent work!
Congratilations !
Just a small issue that i noticed. If i use this with tables, and define the paginations witdh is limited by the first colgroup width
It would be nice if you expose the “Page” “Previous Page” and so on. This way would be easier to localize the plugin.
Could I turn off the intra-page fading?
@diego thx for liking the plugin. Can I look the table code where you are applying pagination. & about the sequence… you download the uncompressed version and change the page sequence in code as you like.
@justin Yes sure, download uncompressed version of plugin and find this line “function appendContent(page, effect)” in code. Replace effect with 1 save it, that’s it.
This looks like it could be a nice plugin but it won’t work for me due to its lack of support for jQuery.noConflict mode. Please please PLEASE add support for this in the future!
VERY NICE! Okay, I had problems where I needed to use CSS to pull the paginator class item out of the flow of a table (it would NOT work with the id of the table but putting the id on the tbody did work) and gave it an absolute position above the table. Needless to say, that destroyed the “both” option!
THANKS!
@james sure I am working on that.
@DK yes “both” option won’t work if you use id. Good to know you made it working for you.
I tried your plugin. It worked without a problem. It’s easy to use. Good job.
I noticed that there is no option to show the number of active items displayed from one page to another. For example: Displaying 11 of 100 items… and when user clicks to go to the next page, then it shows Displaying 21 of 100 items and so on. I was trying to do it myself but my knowledge of jquery proved to be insufficient
How can we add this option?
Thank you in advance.
@Nicholas there is option for showing something like Page 3 of 6 for which you have to set enablePageOfOption = true; // it shows on which page are you on currently, i.e. Page 3 of 6 , if turned true
The option you wants requires some additional modifications in plugin. I may work on it this weekend… but no promises
Actually I did it. I tried to keep your coding structure in tact.
// the option:
var showNumberOfItems = true; // shows ‘Displaying 1-10 of 100 items’
// added the following before switch statement:
var allPageItems = paginatorId.children().length;
var pageStartItem = ((currentPage*itemsPerPage)-itemsPerPage)+1;
var pageLastItem = (currentPage*itemsPerPage);
if(currentPage == 1)
{
pageStartItem = 1;
pageLastItem = itemsPerPage;
}
else if (currentPage == lastPage)
{
pageLastItem = allPageItems;
}
var currentPageInterval = pageStartItem+’ – ‘+pageLastItem;
var displayItemInterval = ‘Displaying ‘+currentPageInterval+’ of ‘+allPageItems+’ items’;
// if selected show it
if(showNumberOfItems)
style += ” + displayItemInterval + ”;
It works.
@Nicholas oh great!! that really looks good.
Actually I started doing some more modification on it on my end. Styling of the pagination wasn’t appropriate for what I was doing. So I extended the paginatorStyle option to include 3 more styling… surely I can see that I started changing your plugin drastically depending on my needs.
I think that you can add the above showNumberOfItems option to the plugin as well. It might be useful for some people.
Thank you again for the plugin.
your plugin works fine but not with a div loaded with ajax.
it’s me have make a mistake or not?
@NA3 try applying the pagination after the content is loaded in the div.
Hi Rohit,
gud plugin.
i have one problem i.e it is not working on tables.
i have given tabled a id and using this plugin
it is not working
plz help.
Is it possible to have multiple paginated divs on the same page?
How to use this with php+mysql.
Need a example tutorial URGENTLY. Thank you.
@Asoj, if you want to use it as ajax then it won’t work. Otherwise you pull up all the data in a content div and then apply the plugin on it.
@admin, I actually need to use pagination in my project!
The data comes from mysql through php. Now in that case, its quite obvious that the table content in sql can significantly grow to very large number, and hence pulling out all data in a content div, and then paginating it, wont be possible!
The possible thing that I think is to use ajax calls n call data from database only on clicking the page number! Can you help me out with this please. I’ve searched a lot about this, but in every tutorial, there exists atleast some mistakes that i’m not able to rectify. I’m a student and not a expert programmer, n so, m stuck! Please advise!!
Thank you.
Rohit, I searched various plugins for pagination with Jquery and this was the best.
Very easy of implement. Thank you.
thank for the cool plugin
Hi! Thanks for the plugin! It works great!! I modified your plugin to include classes the first/last pages and the next/previous, so I could hide them when they are inactive.
.paginator .first-page.inactive, .paginator .previous-page.inactive, .paginator .last-page.inactive, .paginator .next-page.inactive {
display:none;
}
Might want to include the classes in your plugin for those that want to customize the first and last link etc… with an image instead.
Thanks again!! Amazing work.
thank you for this great plugin, i’ve been looking for something like this for a while. The idea of simplicity is great. Keep up the good work!
Excellent work!
Congratilations !
sencs men

you wrili help me
Very nice and simple Paginator. Thanks a lot ! It was very helpful !
Hi, thank you for this simple and effective plugin!
Hi Rokit,
This is am awesome code. I am new to jquery. I have used
initPaginator(); instead of $(“#mydiv”).pagination(); to prevent duplication of page number but I am getting this error
“paginatorId.children is not a function” in firefox.
Any clue will be helpful.
Thanks.
How does this function work with a table result in a PHP While loop? Thanks.
Hi,
Thanks – nice plugin.
Only question I have is can you control the number of page ‘blocks’ that appear.
eg For option ’3′, I want to limit the blocks to:
(clicking on > takes the user to the next page)
Currently I get
Is this possible?
Thanks!
My brother suggested I would possibly like this website. He used to be entirely right. This publish truly made my day. You cann’t imagine simply how much time I had spent for this info! Thanks!
Hi Rohit,
I love the plugin… it is the best one I have found on the internet to date.
Can I make a couple of suggestions for your next version.
1. Include an option to limit the number of page links shown at one time.
Eg. You have 100 results with 5 items per page, you will have 20 page links on the page. Limit this to only show 5 page links that cycle through.
2. Include option to show displaying number of items instead of pages.
Eg. Displaying 21 – 30 of 100 items
I think these would be great additions to your plugin, but anyway… keep up the good work.
Cheers
Well, this is considered as best pagination plug in for jQuery BUT this is not 100% customization :S
Hi Rohit, great job with the plug-in. Simple to use, and very elegant. Just what I needed. Why don’t you put this on the jQuery plugin site?