利用jQuery實(shí)現(xiàn)一個(gè)簡(jiǎn)單的表格上下翻頁效果
前言
本文主要介紹的是利用jQuery實(shí)現(xiàn)一個(gè)簡(jiǎn)單的表格上下翻頁效果,注:實(shí)現(xiàn)原理與輪播圖相似。下面話不多說,來看看詳細(xì)的 實(shí)現(xiàn)方法吧。
html:
<div class="popup day02-popup04"> <div class="group-caption"> <span>日期</span><span>參與團(tuán)購(gòu)場(chǎng)次</span><span class="result">團(tuán)購(gòu)結(jié)果</span><span>當(dāng)前狀態(tài)</span> </div> <table class="group-buying-table J_group_buying_table"> <tr><td>02.08</td><td>第一場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.09</td><td>第二場(chǎng)</td><td>失敗</td><td>G幣已退回</td></tr> <tr><td>02.10</td><td>第三場(chǎng)</td><td>團(tuán)購(gòu)中</td><td>團(tuán)購(gòu)中</td></tr> <tr><td>02.11</td><td>第一場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.12</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.13</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.14</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.15</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.16</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.17</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.18</td><td>第二場(chǎng)</td><td>成功</td><td>G幣已退回</td></tr> <tr><td>02.19</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.20</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.21</td><td>第二場(chǎng)</td><td>成功</td><td>團(tuán)購(gòu)中</td></tr> <tr><td>02.22</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.23</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</td></tr> <tr><td>02.24</td><td>第二場(chǎng)</td><td>成功</td><td>G幣已退回</td></tr> <tr><td>02.25</td><td>第二場(chǎng)</td><td>成功</td><td>現(xiàn)金券已發(fā)放</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, //每頁顯示的行數(shù) len=$groupTable.find('tbody tr').length,//總行數(shù) page= 1, //起始頁 maxPage=Math.ceil(len/i), //總頁數(shù) $tbody=$groupTable.find('tbody'), //容器 $scrollHeight=$groupTable.height(); //滾動(dòng)距離 //下翻按鈕 $(".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--; } } });
總結(jié)
以上就是利用利用jQuery實(shí)現(xiàn)一個(gè)表格的簡(jiǎn)單上下翻頁的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對(duì)腳本之家的支持。
- 基于Jquery實(shí)現(xiàn)表格動(dòng)態(tài)分頁實(shí)現(xiàn)代碼
- 基于jquery實(shí)現(xiàn)的表格分頁實(shí)現(xiàn)代碼
- JQuery頁面的表格數(shù)據(jù)的增加與分頁的實(shí)現(xiàn)
- jquery 表格分頁等操作實(shí)現(xiàn)代碼(pagedown,pageup)
- 擴(kuò)展jquery實(shí)現(xiàn)客戶端表格的分頁、排序功能代碼
- 基于jQuery實(shí)現(xiàn)的無刷新表格分頁實(shí)例
- 基于jquery實(shí)現(xiàn)表格無刷新分頁
- jQuery給表格添加分頁效果
相關(guān)文章
輕松學(xué)習(xí)jQuery插件EasyUI EasyUI實(shí)現(xiàn)樹形網(wǎng)絡(luò)基本操作(2)
這篇文章主要幫助大家輕松學(xué)習(xí)jQuery插件EasyUI,針對(duì)EasyUI實(shí)現(xiàn)樹形網(wǎng)絡(luò)基本操作,分為三大方面:動(dòng)態(tài)加載、添加分頁、以及惰性加載節(jié)點(diǎn),感興趣的小伙伴們可以參考一下2015-11-11利用jQuery實(shí)現(xiàn)漂亮的圓形進(jìn)度條倒計(jì)時(shí)插件
jQuery Final Countdown是一款時(shí)尚的圓形進(jìn)度條樣式的jQuery倒計(jì)時(shí)插件。本篇文章給大家分享利用jQuery實(shí)現(xiàn)漂亮的圓形進(jìn)度條倒計(jì)時(shí)插件,感興趣的朋友一起看看吧2015-09-09ASP.NET中使用后端代碼注冊(cè)腳本 生成JQUERY-EASYUI的界面錯(cuò)位的解決方法
上一篇解決了用了JQUERY-EASYUI時(shí) 后端注冊(cè)腳本重復(fù)執(zhí)行的問題.今天又發(fā)現(xiàn),通過后端代碼 生成的界面有錯(cuò)位現(xiàn)象.2010-06-06jquery獲取file表單選擇文件的路徑、名字、大小、類型
今天小編就為大家分享一篇關(guān)于jquery獲取file表單選擇文件的路徑、名字、大小、類型,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2019-01-01Jquery簡(jiǎn)單實(shí)現(xiàn)GridView行高亮的方法
這篇文章主要介紹了Jquery簡(jiǎn)單實(shí)現(xiàn)GridView行高亮的方法,實(shí)例分析了jQuery頁面元素的選擇與屬性操作的相關(guān)技巧,需要的朋友可以參考下2015-06-06Jquery Post處理后不進(jìn)入回調(diào)的原因及解決方法
通過Jquery的Post方法把Json數(shù)據(jù)傳到Jsp后臺(tái),處理后卻怎么都不進(jìn)入回調(diào)函數(shù),解決方法如下2014-07-07基于jquery實(shí)現(xiàn)省市聯(lián)動(dòng)效果
這篇文章主要介紹了基于jquery實(shí)現(xiàn)省市聯(lián)動(dòng)效果,感興趣的小伙伴們可以參考一下2015-11-11