日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

模拟分页效果

發(fā)布時(shí)間:2023/12/19 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 模拟分页效果 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

css部分:

<style type="text/css">.main{width:800px;zoom:1;margin:0 auto;}.item{width:800px;overflow:hidden;}ul{padding:0;width:860px;zoom:1;}.clear{zoom:1;}.clear:after{content:"";display:block;height:0;clear:both;visibility:hidden;}ul li{list-style-type:none;float:left;background:#F69;font-size:60px;text-shadow:1px 1px 3px #555;width:380px;height:200px;margin:10px 40px 10px 0;line-height:200px;text-align:center;color:#fff;}.page_btn{padding-top:20px;}.page_btn a{cursor:pointer;padding:5px;border:solid 1px #ccc;font-size:12px;}.page_box{float:right;}.num{padding:0 10px;}</style>

html部分:

<div class="main"><div class="item"><ul class="clear"><li>1</li><li>2</li><li>3</li><li>4</li><li style="background: yellowgreen">5</li><li style="background: yellowgreen">6</li><li style="background: yellowgreen">7</li><li style="background: yellowgreen">8</li><li>9</li><li>10</li><li>11</li><li>12</li><li>13</li><li>14</li><li>15</li><li>16</li><li>17</li><li>18</li><li>19</li><li>20</li><li>21</li><li>22</li><li>23</li><li>24</li><li>25</li><li>26</li><li>27</li><li>28</li></ul></div><div class="page_btn clear"><span class="page_box"><a class="prev">上一頁</a><span class="num"><span class="current_page">1</span><span style="padding:0 3px;">/</span><span class="total"></span></span><a class="next">下一頁</a></span></div> </div>

js部分:(此處需要引入jquery.js)

<script type="text/javascript">$(document).ready(function(){$("ul li:gt(0)").hide();//初始化,前面4條數(shù)據(jù)顯示,其他的數(shù)據(jù)隱藏。var total_q=$("ul li").index()+1;//總數(shù)據(jù)var current_page=1;//每頁顯示的數(shù)據(jù)var current_num=1;//當(dāng)前頁數(shù)var total_page= Math.round(total_q/current_page);//總頁數(shù) var next=$(".next");//下一頁var prev=$(".prev");//上一頁 $(".total").text(total_page);//顯示總頁數(shù) $(".current_page").text(current_num);//當(dāng)前的頁數(shù)//下一頁 $(".next").click(function(){if(current_num==28){return false;//如果大于總頁數(shù)就禁用下一頁 }else{$(".current_page").text(++current_num);//點(diǎn)擊下一頁的時(shí)候當(dāng)前頁數(shù)的值就加1 $.each($('ul li'),function(index,item){var start = current_page* (current_num-1);//起始范圍var end = current_page * current_num;//結(jié)束范圍if(index >= start && index < end){//如果索引值是在start和end之間的元素就顯示,否則就隱 $(this).show();}else {$(this).hide();}});}});//上一頁方法 $(".prev").click(function(){if(current_num==1){return false;}else{$(".current_page").text(--current_num);$.each($('ul li'),function(index,item){var start = current_page* (current_num-1);//起始范圍var end = current_page * current_num;//結(jié)束范圍if(index >= start && index < end){//如果索引值是在start和end之間的元素就顯示,否則就隱藏 $(this).show();}else {$(this).hide();}});}})})</script>

?

轉(zhuǎn)載于:https://www.cnblogs.com/shanhaihong/p/5691226.html

總結(jié)

以上是生活随笔為你收集整理的模拟分页效果的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。