日期:2014-05-16 浏览次数:20431 次
<span id="prePages"></span>
<div id="pageNav"></div>
<span id="nextPages"></span>
<script>
crPage(1000, 10, 23);
function crPage(rn, pn, i){
var tpn = Math.ceil(rn/pn);
$("#pageNav").html("");
if(i >= 10){
$("#prePages").html("<a href='' onclick='crPage("
+ rn + ","
+ pn + ","
+ (i-10)
+ ")'>前10页</a>");
}else{
$("#prePages").html("前10页");
}
for(j = Math.floor(i/10)*10+1 ; j < Math.floor(i/10)*10+10; j++){
if(j == i){
$("#pageNav").html($("#pageNav").html() + "<span class='numBlock'>"+j+"</span> ");
continue;
}
if(j <= tpn){
$("#pageNav").html(
$("#pageNav").html()
+"<span class='numBlock'>"
+"<a href='#' onclick='crPage("
+ rn + ","
+ pn + ","
+ j + ")'>"
+ j +"</a></span> ");
}
}
if(i <= tpn){
$("#nextPages").html("<a href='' onclick='crPage("
+ rn + ","
+ pn + ","
+ (i+10)
+ ")'>后10页</a>");
}else{
$("#nextPages").html("后10页");
}
}
</script>