複製程式碼 程式碼如下: <br> $(function(){<br> //此demo通过Ajax加载分页元素<br> var initPagination = function(data) {</p> <p> var feedback = "";</p> <p> $.each(data.list, function(index, d) { <br> var str =""; <br> str+= "<dl class='result' style='display:none;'>";<br> str+="<dt><img src='http://www.jb51.net/headshotsByName/balijiang.png?l' alt='图片' width='70' height='70' /></dt>";<br> str+="<dd><a href='#' title='VYyu'>VYyu</a></dd>";<br> str+="<dd class='gray'>2009-09-26 </dd>";<br> str+="<dd>"+d+"</dd>";<br> str+="</dl>";<br> feedback += str; <br> }); <br> $("#feedback").empty().append(feedback); //装载对应分页的内容</p> <p> //alert(datac.list.length);<br> <br> 分頁<br> $("#page").pagination(num_entries, {<br> : 1, //邊緣頁數<br> num_display_ callback: pageselectCallback,<br> items_per_page: 3, //每頁顯示1項 next_text: "後一頁" pageselectCallback(0);<br> <br>function pageselectCallback(page_index, jq){<br> </p> var resultList = $(".result");<p> //var feedback = "";<br> //alert(resultList.length);</p> //alert(resultList.length);<p> //alert(resultList.length);</p> function(index, data) { <p> //alert(index);<br> Math.floor(index/3) = = page_index){<br> $(this).css('display','block');<br> <br> return false;<br>}<br>//ajax載入<br>$.getJSON("testPage",null, function(data){initPagination(data)});<br>});<br>});</p> <p> <br><br> <br></p> <br> <br><div id="feedback" class="feedback"> </div> <p></p> <div id="page" class="pager"></div> <p> </p> </div>