• JS, Jquery进行前台翻页


    这里我们是根据table来进行前台翻页,这里只有上下翻页,没有直接到第一页和到最后一页

    function goPage(pno,psize){//pon就是从第几页开始,psize就是几条为一页
    var itable = document.getElementById("myTab1");//此id就是table的id
    var num = itable.rows.length-1;
    var totalPage = 0;
    var pageSize = psize;
    if(num/pageSize > parseInt(num/pageSize)){
    totalPage=parseInt(num/pageSize)+1;
    }else{
    totalPage=parseInt(num/pageSize);
    }
    var currentPage = pno;
    var startRow = (currentPage - 1) * pageSize+1;
    var endRow = currentPage * pageSize;
    endRow = (endRow > num)? num : endRow;
    for(var i=1;i<(num+1);i++){
    var irow = itable.rows[i];
    if(i>=startRow && i<=endRow){
    irow.style.display = "block";
    }else{
    irow.style.display = "none";
    }
    }

    var tempStr = "";
    if(currentPage>1){
    tempStr += "<a href="#" onClick="goPage("+(currentPage-1)+","+psize+")"><img src='/images/arrow_up.gif' border='0'></a>"
    }
    if(currentPage<totalPage){
    tempStr += "<a href="#" onClick="goPage("+(currentPage+1)+","+psize+")"><img src='/images/arrow_down.gif' border='0'></a>";
    }
    document.getElementById("barcon").innerHTML = tempStr;//此id就是翻页的图标插入的地方
    }

    <table width="100%" style="padding-top: 10px;">
    <tr>
    <td><div id="barcon" name="barcon"></div></td>
    </tr>
    </table>

  • 相关阅读:
    php冒泡排序
    解决ubuntu下安装phpmyadmin访问不了的问题
    反省
    mysql主从复制
    ubuntu14.04 安装 bcm43142无线网卡
    mysql 批量更新和批量插入
    chromium 安装 pepper flash player
    js prototype新感悟
    读《乌合之众》
    马云---我的世界永不言败
  • 原文地址:https://www.cnblogs.com/echo777/p/6805814.html
Copyright © 2020-2023  润新知