在做项目的时候,要求使用ajax的无刷新的分页,可以由于自己对pagerhealp类不是很熟悉,所以就放弃这个念头。想起以前用sql 的存储过程来写的分页,于是就想使用javascript和Jquery来写了一个分页的程序,下面只把分页的功能写出来,Jquery的ajax请求就省略了。
1
function Pagers(page)
2
{
3
var div=document.createElement("div");
4
div.id="bar";
5
document.getElementById("pager").appendChild(div);
6
var j=(page-3<1)?1:page-3;
7
var k=(page+3>maxpage)?maxpage:page+3;
8
if(j>1)
9
{
10
var a=document.createElement("a");
11
a.href="#";
12
a.innerHTML="
";
13
document.getElementById("bar").appendChild(a);
14
}
15
for(var i=j;i<k+1;i++)
16
{
17
if(i!=k)
18
{
19
var a=document.createElement("a");
20
var s=i;
21
a.href="javascript:reloadpager();Pagers("+i+");";
22
a.innerHTML=i;
23
document.getElementById("bar").appendChild(a);
24
continue;
25
}
26
if(maxpage>k)
27
{
28
var a=document.createElement("a");
29
a.href="#";
30
a.innerHTML="
";
31
document.getElementById("bar").appendChild(a);
32
var a=document.createElement("a");
33
a.href="#";
34
a.onclick="reloadpager();Pagers("+maxpage+");";
35
a.innerHTML=maxpage;
36
document.getElementById("bar").appendChild(a);
37
}
38
}
39
40
}
41
function reloadpager()
42
{
43
var pp=document.getElementById("bar");
44
document.getElementById("pager").removeChild(pp);
45
}
也许对大家有帮助!
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
3
![](/Images/OutliningIndicators/InBlock.gif)
4
![](/Images/OutliningIndicators/InBlock.gif)
5
![](/Images/OutliningIndicators/InBlock.gif)
6
![](/Images/OutliningIndicators/InBlock.gif)
7
![](/Images/OutliningIndicators/InBlock.gif)
8
![](/Images/OutliningIndicators/InBlock.gif)
9
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
13
![](/Images/OutliningIndicators/InBlock.gif)
14
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
15
![](/Images/OutliningIndicators/InBlock.gif)
16
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/InBlock.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/InBlock.gif)
25
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
26
![](/Images/OutliningIndicators/InBlock.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/InBlock.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
31
![](/Images/OutliningIndicators/InBlock.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/InBlock.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
38
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
41
![](/Images/OutliningIndicators/None.gif)
42
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/InBlock.gif)
45
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)