47
var page_size=3;
1
< HTML >
2
< Head >
3
< Meta http-equiv= "content-type"Content="text/html; Charset=utf-8 ">
4
< title > Insert title here</title>
5
< Script type=' text/javascript 'src=' jquery.js '></script >
6
< style type="text/css">
7
Span{width:60px;height:20px;display:inline-block;border:solid 1px black;text-align:center;margin:5px;cursor: pointer;}
8
</ style >
9
</ Head >
10
< Body >
11
< Div id=' page '></div>
12
< Div id=' con '></div>
13
< Script type=' text/javascript '>
14
var arr=new Array (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
15
/*
16
Show the contents of that page
17
Arr content array, the page from which to start displaying, Len is the number of items per page displayed
18
*/
19
function Pagecon (Arr,start,len) {
20
var constr= ';
21st
for (Var i=start;i<start+len;i++) {
22
if (Arr[i-1]) {
23
constr+=arr[i-1]+"<br/>";
24
}
25
}
26
return Constr;
27
}
28
function Show (arr,now_page) {
29
var sum=arr.length;
30
var page_size=3;
31
var page_num=Math.ceil (sum/page_size);
32
var Start=(now_page-1) *page_size+1;
33
var page_str=";
34
For (vari=1;i<=page_num;i++) {
35
var stylei=i;
36
if (i==now_page) { stylei= "<spanstyle=' Background:black;color:white;margin : 0 '>"+i+"</span>";}
37
page_str+= '<spanonclick=' Show (arr, ' +i+ ') '>' +stylei+ '</span>';
38
}
39
$ (' #page '). HTML (PAGE_STR);
40
var constr=pagecon (arr,start,page_size);
41
$ (' #con '). HTML (CONSTR);
42
}
43
Show (arr,2);
44
</ Script >
45
</ Body >
46
</ HTML >
JS page code sharing