国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

利用jQuery實現一個簡單的表格上下翻頁效果

2019-11-19 17:09:19
字體:
來源:轉載
供稿:網友

前言

本文主要介紹的是利用jQuery實現一個簡單的表格上下翻頁效果,注:實現原理與輪播圖相似。下面話不多說,來看看詳細的 實現方法吧。

html:

<div class="popup day02-popup04">  <div class="group-caption">   <span>日期</span><span>參與團購場次</span><span class="result">團購結果</span><span>當前狀態</span>  </div>  <table class="group-buying-table J_group_buying_table">   <tr><td>02.08</td><td>第一場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.09</td><td>第二場</td><td>失敗</td><td>G幣已退回</td></tr>   <tr><td>02.10</td><td>第三場</td><td>團購中</td><td>團購中</td></tr>   <tr><td>02.11</td><td>第一場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.12</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.13</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.14</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.15</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.16</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.17</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.18</td><td>第二場</td><td>成功</td><td>G幣已退回</td></tr>   <tr><td>02.19</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.20</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.21</td><td>第二場</td><td>成功</td><td>團購中</td></tr>   <tr><td>02.22</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.23</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>   <tr><td>02.24</td><td>第二場</td><td>成功</td><td>G幣已退回</td></tr>   <tr><td>02.25</td><td>第二場</td><td>成功</td><td>現金券已發放</td></tr>  </table>  <p class="popup-page-btn">   <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="prev">上一頁</a>   <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="next">下一頁</a>  </p>  <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="popup-close J_close"></a> </div> 

css:

.day02-popup04 {  width: 708px;  height: 404px; }  .day02-popup04 .group-caption {  width: 594px;  margin: 30px auto 0;  border-top: 1px solid #ccc;  border-left: 1px solid #ccc;  border-bottom: 1px solid #ccc; }  .day02-popup04 .group-caption span {   width: 147.5px;   display: inline-block;   border-right: 1px solid #ccc;   text-align: center;   height: 50px;   line-height: 50px;   font-weight: 600;   font-size: 20px; }  .day02-popup04 .group-buying-table {  position: relative;  width: 594px;  margin: 0 auto;  height: 255px;  overflow: hidden;  border-collapse: collapse; }  .day02-popup04 .group-buying-table tbody {   position: absolute;   top: 0; }   .day02-popup04 .group-buying-table tbody tr {   height: 50px;   line-height: 50px; }   .day02-popup04 .group-buying-table tbody tr td {    width: 147px;    border-left: 1px solid #ccc;    border-right: 1px solid #ccc;    border-bottom: 1px solid #ccc;    text-align: center;    font-size: 18px;    color: #666; }  .day02-popup04 .popup-page-btn {  position: absolute;  width: 100%;  bottom: 0;  height: 66px;  line-height: 66px;}  .day02-popup04 .popup-page-btn a {   display: inline-block;   text-align: center;   width: 142px;   margin: 0 12px;   height: 42px;   line-height: 42px;   font-size: 20px;   color: #fff;   background-color: #bf3737; } 

js代碼:

var i= 5, //每頁顯示的行數      len=$groupTable.find('tbody tr').length,//總行數      page= 1,        //起始頁      maxPage=Math.ceil(len/i),    //總頁數      $tbody=$groupTable.find('tbody'),  //容器      $scrollHeight=$groupTable.height();  //滾動距離     //下翻按鈕     $(".next").click(function(e){      if(!$tbody.is(":animated")){       if(page == maxPage ){        $tbody.stop();       }else{        $tbody.animate({top : "-=" + $scrollHeight +"px"},800);        page++;       }      }     });     //上翻按鈕     $(".prev").click(function(){      if(!$tbody.is(":animated")){       if(page == 1){        $tbody.stop();       }else{        $tbody.animate({top : "+=" + $scrollHeight +"px"},800);        page--;       }      }     }); 

總結

以上就是利用利用jQuery實現一個表格的簡單上下翻頁的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對武林網的支持。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 康平县| 湘潭县| 甘谷县| 大名县| 兴仁县| 沙河市| 临西县| 门源| 涟源市| 视频| 龙州县| 遵化市| 扎鲁特旗| 全南县| 宜阳县| 隆尧县| 手机| 如皋市| 株洲县| 望城县| 宁武县| 平顺县| 宝兴县| 公安县| 焉耆| 射阳县| 和政县| 巩义市| 清新县| 浦北县| 莱西市| 南江县| 华坪县| 峨眉山市| 正宁县| 五台县| 泸州市| 赤壁市| 于田县| 闽侯县| 临邑县|