A small plug-in for paging with prototype

Source: Internet
Author: User

(function (win, undefined) {
var Pagefen = Win.pagefen = function (inforallcount) {
This.nowpage = 1; Current page
This.pagecount = 10; One-time load of 10
How many pages are there in total
This.pageallcount = (inforallcount% This.pagecount = = 0?) (Inforallcount/this.pagecount): (parseint (Inforallcount/this.pagecount) + 1));

};
Previous page method (current page, number of bars displayed per page)
Pagefen.prototype.uppage = function (Nowpage, PageCount) {
This.nowpage-= 1;
This.nowpage = (This.nowpage = = 0? 1:this.nowpage)
Pagecontrol.seach (This.nowpage, This.pagecount);
}
Next Page method
Pagefen.prototype.nextpage = function (Nowpage, PageCount) {
This.nowpage + = 1;
This.nowpage = (This.nowpage = = (This.pageallcount + 1)? this.pageAllcount:this.nowpage);
Pagecontrol.seach (This.nowpage, This.pagecount);
}
} (window));

Query method
var Pagecontrol = {
Seach:function (Nowpage, PageCount) {
var Pagefirst = (nowpage-1) * PageCount + 1; 1 Piece of data
var pageend = nowpage * PageCount; 10 Piece of data
$ ('. Addlistul li '). Hide ();
$ ('. Addlistul li '). Slice (pagefirst-1, pageend). Show ();
}
};

$ (function () {

Here is where to get the data added to UL inside
var ele = $ ('. Addlistul ');
for (var i = 0; i <; i++) {
Ele.append ("<li>" + (i + 1) + "</li>");
}

instantiating pagination
var pagemethod = new Pagefen (100);
Pagecontrol.seach (1, 10);
Previous page modify Current page plus one
$ ('. Have_small '). Click (function () {
Pagemethod.uppage (This.nowpage, This.pagecount);
});
Next page Modify Current page minus one
$ ('. Next_page '). Click (function () {
Pagemethod.nextpage (This.nowpage, This.pagecount);
});

Click on the number to display the first few pages
$ ('. Num '). Click (function () {
var getnumpage = parseint ($ (this). text ());

The currently selected number of pages and then calls the Query method

Pagecontrol.seach (Getnumpage, 10);
Pagemethod.nowpage = Getnumpage;
});

});

<div class= "R-h-3" >
<ul class= "Addlistul" ></ul>
</div>

A small plug-in for paging with prototype

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.