複製程式碼 代碼如下: 代碼如下: Insert title here <BR>span{width: 60px;height: 20px;display: inline -block;border: solid 1px black;text-align: center;margin: 5px;cursor:pointer;}<BR> <BR> var arr=new Array(1,2, 3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);<BR> /*<BR> 顯示那一頁的內容<BR> arr內容陣列,那頁的從哪一開始顯示的,len就是每頁顯示內容條數<BR> */<BR> function pageCon(arr,start,len){ var constr='';<P> for(var i=start;i<start len;i ){<BR> if(arr[i-1]){<BR> constr =arr[i-1] "<br/>"; constr =arr[i-1] "<br/>";<P> <BR> <BR> }<BR> return constr;<BR> }<BR> <BR>function show(arr,now_page){<BR> var sum=arr.length;<BR> var page_size=3;<BR> var page_num=Math.ceil(sum/page_size);<; (now_page-1)*page_size 1;<BR> var page_str='';<BR> for(var i=1;i<=page_num;i ){ var stylei=i;<P> ==now_page){ stylei="<span style='background:black;color:white;margin:0'>" i "";}<BR> page_str ='<spanonclick="show(arr ,' i ')">' stylei ''; }<P> $('#page').html(page_str);<BR> <BR> var constr=pageCon(arr,start,page_size);<BR> $('#con').html(constr);<BR> <BR>} show(arr,2);