JS page code sharing

Source: Internet
Author: User

<textarea spellcheck="false" style="position: absolute; bottom: -1em; padding: 0px; width: 1000px; height: 1em; outline: none" tabindex="0" readonly=""></textarea>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

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.