帮助中心
获取牛币
联系我们
关于我们
版权声明
素材牛首页
微博登录
QQ登录
微信扫码登录
注册
登录
新浪微博
QQ登陆
微信登录
热门搜索:
小程序
支付
Java
后台模板
上传
商城模板
jQuery
手机
Thinkphp
微信
Vue.js
首 页
网页特效
整站源码
PHP实例
网站模版
工具箱
常用代码
论坛
游戏源码
资源分享
当前位置:
首页
»
精选常用代码
» 简洁实用的分页功能
简洁实用的分页功能
浏览:631次
-
评论:0次
-
发布时间:2017-05-10
Html
Css
Js
* { padding:0px; margin:0px; } ul li { list-style-type:none; } .ul_btn { overflow:hidden; padding:10px; } .ul_btn li { float:left; height:30px; text-align:center; line-height:30px; border:1px solid #ddd; border-radius:4px; margin-left:5px; padding:0px 10px; box-shadow:0px -1px 5px #c8c8c8 inset; font-size:12px; cursor:pointer; } .ul_btn li.active { box-shadow:none; height:25px; margin-top:5px; } .ul_btn li.noneBtn { background-color:#f5f5f5; box-shadow:none; cursor:auto; } .ul_btn li.otherLi { box-shadow:none; cursor:auto; }
$(function() { changePage($("#inp_allPage").val(), $("#inp_page").val()); }); function changePage(allPage, thisPage) { $(".ul_btn").text(""); var allPage = parseInt(allPage); var thisPage = parseInt(thisPage); var page_html = ''; page_html += '
首页
'; page_html += '
上一页
'; if (thisPage - 3 > 0) { page_html += '
1
'; if (thisPage - 4 > 0) { page_html += '
...
'; } } if (thisPage - 2 > 0) { page_html += '
' + (thisPage - 2) + '
'; } if (thisPage - 1 > 0) { page_html += '
' + (thisPage - 1) + '
'; } page_html += '
' + thisPage + '
'; if (thisPage + 1 <= allPage) { page_html += '
' + (thisPage + 1) + '
'; } if (thisPage + 2 <= allPage) { page_html += '
' + (thisPage + 2) + '
'; } if (thisPage + 3 <= allPage) { if (thisPage + 3 < allPage) { page_html += '
...
'; } page_html += '
' + allPage + '
'; } page_html += '
下一页
'; page_html += '
尾页
'; $(".ul_btn").append(page_html); } function lastPage() { var allPage = parseInt($("#inp_allPage").val()); var thisPage = parseInt($("#inp_page").val()); if ((thisPage - 1) > 0) { thisPage--; $("#inp_page").val(thisPage); changePage(allPage, thisPage); $(".firstPage").removeClass("noneBtn"); $(".lastPage").removeClass("noneBtn"); if ((thisPage - 1) == 0) { $(".firstPage").addClass("noneBtn"); $(".lastPage").addClass("noneBtn"); } $(".nextPage").removeClass("noneBtn"); $(".endPage").removeClass("noneBtn"); } } function nextPage() { var allPage = parseInt($("#inp_allPage").val()); var thisPage = parseInt($("#inp_page").val()); if (thisPage < allPage) { thisPage++; $("#inp_page").val(thisPage); changePage(allPage, thisPage); if ((allPage - thisPage) == 0) { $(".nextPage").addClass("noneBtn"); $(".endPage").addClass("noneBtn"); } $(".firstPage").removeClass("noneBtn"); $(".lastPage").removeClass("noneBtn"); } } function firstPage() { var allPage = parseInt($("#inp_allPage").val()); thisPage = 1; $("#inp_page").val("1"); changePage(allPage, thisPage); $(".firstPage").addClass("noneBtn"); $(".lastPage").addClass("noneBtn"); $(".nextPage").removeClass("noneBtn"); $(".endPage").removeClass("noneBtn"); } function endPage() { var allPage = parseInt($("#inp_allPage").val()); var thisPage = allPage; $("#inp_page").val(allPage); changePage(allPage, thisPage); $(".firstPage").removeClass("noneBtn"); $(".lastPage").removeClass("noneBtn"); $(".nextPage").addClass("noneBtn"); $(".endPage").addClass("noneBtn"); } function normalPage(o) { var allPage = parseInt($("#inp_allPage").val()); var thisPage = parseInt($(o).text()); $("#inp_page").val($(o).text()); changePage(allPage, thisPage); if (thisPage == 1) { $(".firstPage").addClass("noneBtn"); $(".lastPage").addClass("noneBtn"); } else { $(".firstPage").removeClass("noneBtn"); $(".lastPage").removeClass("noneBtn"); } if (thisPage == allPage) { $(".nextPage").addClass("noneBtn"); $(".endPage").addClass("noneBtn"); } }
↑上面代码改变,会自动显示代码结果
jQuery调用版本:
1.9.1
<!doctype html><html><head><meta charset="utf-8"><title>简洁实用的分页功能-www.sucainiu.com</title><script src="https://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script><style>
</style></head><body>
<script>
</script>
</body></html>
立即下载
收藏
积分说明:注册即送10牛币,每日签到可获得5牛币,成为VIP会员可永久免牛币下载!
充值积分
充值会员
更多说明»
代码描述:jquery写的简洁实用的分页效果
TAB标签切换效果
目录树折叠菜单jQuery版(复选框)
讨论这个常用代码(0)
回答他人问题或分享心得会奖励牛币
〒_〒 居然一个评论都没有……
文明上网,理性发言! 😉 阿里云幸运券,
戳我领取
发表评论
提交回复
我的积分余额:
0
已下载次数:
631
所需牛币:
5
开始下载
牛币获取:
签到、评论、充值
» 在线充值
(10牛币=1元)
成为VIP可永久免积分下载全部常用代码
» 查看详情
VIP
客服
签到
充值