JavaScript static paging (multiple data, static automatic paging) _javascript tips

Source: Internet
Author: User
<ptml> <pead> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "> <title> static Paging (end page) www.jb51.net</title> </pead> <body> <style> ul {di Splay:none} </style> <div id= "mydiv" > <ul> <li>01</li> </ul> <ul> <li& gt;02</li> </ul> <ul> <li>03</li> </ul> <ul> <li>04</li> < /ul> <ul> <li>05</li> </ul> <ul> <li>06</li> </ul> <ul> & lt;li>07</li> </ul> <ul> <li>08</li> </ul> <ul> <li>09</li> </ul> <ul> <li>10</li> </ul> <ul> <li>11</li> </ul> <ul& Gt <li>12</li> </ul> <ul> <li>13</li> </ul> <ul> <li>14</li&gt ; </ul> <ul> <li>15</li> </ul> <ul> <li>16</li> </ul> <ul> <li>17</li> </ul> <ul> &L t;li>18</li> </ul> <ul> <li>19</li> </ul> <ul> <li>20</li> </ul> </div> <div id= "changpage" ></div> <script> var obj,j; var page=0; var nowpage=0;//current page var listnum=3;//per page show <ul> number var pageslen;//total pages var pagenum=4;//paging link number (5) onload=function () { Obj=document.getelementbyid ("Mydiv"). getElementsByTagName ("ul"); J=obj.length Pageslen=math.ceil (J/listnum); Uppage (0)} function uppage (p) {nowpage=p//Content transformation for (Var i=0;i<j;i++) {obj[i].style.display= ' None '} for (Var i=p*listnum;i< (p+1) *listnum;i++) {if (Obj[i]) obj[i].style.display= "block"}//Paging link transform strs= ' home    ' var Pag Enum_2=pagenum%2==0? Math.ceil (PAGENUM/2) +1:math.ceil (PAGENUM/2) var pagenum_3=pagenum%2==0? Math.ceil (PAGENUM/2): Math.ceil (PAGENUM/2) +1 var strc= "", startpage,endpage; IF (pagenum>=pageslen) {startpage=0;endpage=pageslen-1} else if (nowpage<pagenum_2) {startpage=0;endpage= Pageslen-1>pagenum? pagenum:pageslen-1}//home else {Startpage=nowpage+pagenum_3>=pageslen? Pageslen-pagenum-1: Nowpage-pagenum_2+1;var T=startpage+pagenum;endpage=t>pageslen? Pageslen-1:t} for (Var i=startpage;i<=endpage;i++) {if (i==nowpage) strc+= ' + (i+1) + '   ' else strc+= ' + (i+1) + ' & nbsp; ' } stre= '   Last    ' stre2=nowpage+1+ '/"+pageslen+" page "+"    Total "+j+" "Strip" document.getElementById (" Changpage "). Innerhtml=strs+strc+stre+stre2} </script> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

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.