JS 无刷新翻页

BODY:

<table width="100%" border="0" cellspacing="0" cellpadding="0" id="idData">
<tr><td></td></tr>

<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100216.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100216.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100222.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100222.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100233.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100233.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100246.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100246.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100253.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100253.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100309.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100309.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100312.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100312.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100318.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100318.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100324.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100324.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100336.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100336.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100356.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100356.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100413.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100413.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100515.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100515.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
<tr style="width:33%; float:left;">
<td><div style=" width:180px; padding:2px; border:1px solid #beb399; height:150px;overflow:hidden; margin-bottom:15px;">
<div style="position:relative; height:150px; display:table-cell;text-align:center; vertical-align:middle"><a href='/uploads/allimg/121203/1-121203100533.jpg' rel="example1" title='' style="position:static;+position:absolute; top:50%"><img src='/uploads/allimg/121203/1-121203100533.jpg' alt='' border='0' style="position:static; +position:relative; top:-50%;left:-50%;" /></a></div></div></td>
</tr>
</table>

<div id="barcon" name="barcon"></div>


JS:
<script>
function goPage(pno,psize){
var itable = document.getElementById("idData");
var num = itable.rows.length;//表格行数
var totalPage = 0;//总页数
var pageSize = 12;//每页显示行数
if((num-1)/pageSize > parseInt((num-1)/pageSize)){
totalPage=parseInt((num-1)/pageSize)+1;
}else{
totalPage=parseInt((num-1)/pageSize);
}
var currentPage = pno;//当前页数
var startRow = (currentPage - 1) * pageSize+1;//开始显示的行
var endRow = currentPage * pageSize+1;//结束显示的行
endRow = (endRow > num)? num : endRow;
//前三行始终显示
for(i=0;i<1;i++){
var irow = itable.rows[i];
irow.style.display = "block";
}
for(var i=1;i<num;i++){
var irow = itable.rows[i];
if(i>=startRow&&i<endRow){
irow.style.display = "block";
}else{
irow.style.display = "none";
}
}
var pageEnd = document.getElementById("pageEnd");
var tempStr = "共 "+totalPage+" 页 ";
if(currentPage>1){
tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage-1)+","+psize+")\">上一页 </a>"
}else{
tempStr += "";
}
if(currentPage<totalPage){
tempStr += "<a href=\"#\" onClick=\"goPage("+(currentPage+1)+","+psize+")\">下一页</a>";
}else{
tempStr += "";
}
if(currentPage>1){
tempStr += "";
}else{
tempStr += "";
}
if(currentPage<totalPage){
tempStr += "";
}else{
tempStr += "";
}
document.getElementById("barcon").innerHTML = tempStr;
}
</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sharecode.site

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值