The project used to pagination, spent some time to finish, summed up, hoping to make everyone less detours. The database is MySQL, using MySQL's limit Start,len
First download: Bootstrap-paginator JS plugin, Address:
And then on the page:
<div id= "pagination" ></div> var options = {currentpage:1,//Totalpages:10, itemcontainerclass:function (type, page, current) {return (page = = current)?
Active ":" Pointer-cursor ";
Itemtexts:function (Type, page, current) {switch (type) {case "a":
Return "Home";
Case "prev": Return "previous Page";
Case "Next": Return "next Page";
Case ' last ': return ' end ';
Case "page": Return page;
}, Onpageclicked:function (e,originalevent,type,page) {e.stopimmediatepropagation ();
var currenttarget = $ (e.currenttarget);
var pages = Currenttarget.bootstrappaginator ("GetPages");
Ajax calling Settabledata (page); Currenttarget.bootsTrappaginator ("Show", page);
Updatepagesinfo ($ ("#totalRecord"). Val (), page);
}, Pageurl:function (type, page, current) {return "#";
}
}; $ (' #pagination '). Bootstrappaginator (options);
The values in options can be set dynamically, such as Options.totalpages = 20, depending on the query condition or the total number of records.
The effect is as follows: