/*列表分页底部按钮*/
div.tablefooter{
color: #4f6d95;
}
select.pageLength{
border: 1px solid #d0daea;
border-radius: 2px;
height: 24px;
color: #4f6d95;
padding-left:3px ;
}
select.pageLength:focus{
border: 1px solid #81c7f7;
outline: none;
}
.pageBtn{
height: 24px;
width: 24px;
background-color: #FFFFFF;
border: 1px solid #d0daea;
border-radius: 2px;
color: #bac3d1;
text-align: center;
/*padding: 1px;*/
font-size: 14px;
cursor:pointer;
display:inline-block;
outline:;
}
.pageBtn:hover{
background-color: #26a2f7;
border: 1px solid #26a2f7;
color: #FFFFFF;
} .firstOrLast{
width: 40px;
} input.pageNo{
width: 30px;
text-align: center;
border-radius: 2px;
padding-left: 0px;
border: 1px solid #d0daea;
height: 22px;
color: #4f6d95;
}
    <div class="tablefooter">
<div class="float-left">
<span >
<select class="select pageLength" name="pageSize" id="pageSize">
<option value="5" selected="selected">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
</select>
条/页
</span>
</div> <div class="float-right">
<span>共100条记录/10页</span>
<button class='pageBtn firstOrLast' id='firstPage'>首页</button>
<button class='pageBtn preOrNextPage' id='prePage'><i class="Hui-iconfont Hui-iconfont-arrow2-left"></i></button>
<button class='pageBtn pageNumBtn'>1</button>
<button class='pageBtn pageNumBtn'>2</button>
<button class='pageBtn pageNumBtn activeBtn'>3</button>
<button class='pageBtn pageNumBtn'>4</button>
<button class='pageBtn pageNumBtn'>5</button>
<button class='pageBtn preOrNextPage' id='nextPage'><i class="Hui-iconfont Hui-iconfont-arrow2-right"></i></button>
<button class='pageBtn firstOrLast' id='lastPage'>末页</button>
<span>跳至<input type='text' class='pageNo'>页</span> </div>
<div class="blank"></div>
</div>
/*
表格分页
* */
// 总页数,每页条数,当前页,总记录数
function setTablePage(totalPage,pageSize,currentPage,totalCount){ var html ="";
// var totalPage = Math.ceil(totalCount / pageSize); html = "<span>共"+totalCount+"条\/"+totalPage+"页</span>\n";
if(currentPage !== 1){
html = html +"<button class='pageBtn firstOrLast' id='firstPage'>首页</button>\n"
+"<button class='pageBtn preOrNextPage' id='prePage'><i class='Hui-iconfont Hui-iconfont-arrow2-left'></i></button>\n";
}
var numBtnCount = 5; //显示页码个数
var startPage,endPage;
if (totalPage <= numBtnCount ) { //页数少于可显示个数 startPage = 1;
endPage = totalPage; } else { // 页数大于可显示个数 if(currentPage <= ((numBtnCount+1)/2)){
startPage = 1;
endPage = numBtnCount; } else if( currentPage < (totalPage-(numBtnCount/2)) ){
startPage = currentPage - parseInt(numBtnCount/2);
endPage = startPage + numBtnCount -1;
} else {
startPage = totalPage - numBtnCount +1;
endPage = totalPage;
}
}
for(var i=startPage;i<= endPage;i++){
if(i === currentPage){
html = html + "<button class='pageBtn pageNumBtn activeBtn'>"+i+"</button>\n";
}else{
html = html + "<button class='pageBtn pageNumBtn'>"+i+"</button>\n";
}
} if(currentPage !== totalPage && totalPage !== 0){
html = html + " <button class='pageBtn preOrNextPage' id='nextPage'><i class='Hui-iconfont Hui-iconfont-arrow2-right'></i></button>\n"
+ "<button class='pageBtn firstOrLast' id='lastPage'>末页</button>\n";
}
if(totalPage > 1 ){ html = html + "<span>跳至<input type='text' class='pageNo' name='pageNo'>页</span>\n" /*+ "<button class='pageBtn' id='pageOkBtn'>确定</button>"*/;
}
$(".tablefooter .float-right").html(html);
$("#pageSize option[value='"+pageSize+"']").prop("selected",true);
}
var data = {pageSize:parseInt($("#pageSize").val()),pageNo:1};
//更换列表长度
$("#pageSize").on("change",function () {
data.pageNo = 1;
if(data.totalPage==0){
return;
}
data.pageSize = parseInt( $("#pageSize").val() );
ajaxReq(data);
}); $(".tablefooter").on("click","#firstPage",function () {
data.pageNo = 1;
ajaxReq(data);
}); $(".tablefooter").on("click","#lastPage",function () {
data.pageNo = data.totalPage;
ajaxReq(data);
});
$(".tablefooter").on("click","#prePage",function () {
data.pageNo = data.pageNo-1;
ajaxReq(data);
});
$(".tablefooter").on("click","#nextPage",function () {
data.pageNo = data.pageNo+1;
ajaxReq(data);
}); $(".tablefooter").on("click",".pageNumBtn",function () { var val = $(this).html();
if(""==val || val == data.pageNo){
return;
}
data.pageNo=parseInt(val);
ajaxReq(data);
}); $(".tablefooter").on("change",".pageNo",function () {
var pageNo = $(".pageNo").val(); if(!pageNo){
return;
}
if(data.totalPage == null || data.totalPage <=0 ){
return;
}
if(pageNo == data.pageNo){
return;
} if(!/^[1-9]\d*$/.test(pageNo)) {//对当前页码进行整数校验
alertToFocus("请输入整数",$(this));
return;
}
if(pageNo > data.totalPage) {//判断当前页码是否大于最大页
alertToFocus("输入页码过大",$(this));
return;
}
data.pageNo = parseInt(pageNo);
ajaxReq(data);
});

html 分页的更多相关文章

  1. 记一次SQLServer的分页优化兼谈谈使用Row_Number()分页存在的问题

    最近有项目反应,在服务器CPU使用较高的时候,我们的事件查询页面非常的慢,查询几条记录竟然要4分钟甚至更长,而且在翻第二页的时候也是要这么多的时间,这肯定是不能接受的,也是让现场用SQLServerP ...

  2. js实现前端分页页码管理

    用JS实现前端分页页码管理,可以很美观的区分页码显示(这也是参考大多数网站的分页页码展示),能够有很好的用户体验,这也是有业务需要就写了一下,还是新手,经验不足,欢迎指出批评! 首先先看效果图: 这是 ...

  3. JdbcTemplate+PageImpl实现多表分页查询

    一.基础实体 @MappedSuperclass public abstract class AbsIdEntity implements Serializable { private static ...

  4. MVC如何使用开源分页插件shenniu.pager.js

    最近比较忙,前期忙公司手机端接口项目,各种开发+调试+发布现在几乎上线无问题了:虽然公司项目忙不过在期间抽空做了两件个人觉得有意义的事情,一者使用aspnetcore开发了个人线上项目(要说线上其实只 ...

  5. NET Core-TagHelper实现分页标签

    这里将要和大家分享的是学习总结使用TagHelper实现分页标签,之前分享过一篇使用HtmlHelper扩展了一个分页写法地址可以点击这里http://www.cnblogs.com/wangrudo ...

  6. 套用JQuery EasyUI列表显示数据、分页、查询

    声明,本博客从csdn搬到cnblogs博客园了,以前的csdn不再更新,朋友们可以到这儿来找我的文章,更多的文章会发表,谢谢关注! 有时候闲的无聊,看到extjs那么肥大,真想把自己的项目改了,最近 ...

  7. php实现的分页类

    php分页类文件: <?php /** file: page.class.php 完美分页类 Page */ class Page { private $total; //数据表中总记录数 pr ...

  8. C#关于分页显示

    ---<PS:本人菜鸟,大手子还请高台贵手> 以下是我今天在做分页时所遇到的一个分页显示问题,使用拼写SQL的方式写的,同类型可参考哦~ ------------------------- ...

  9. JAVA 分页工具类及其使用

    Pager.java package pers.kangxu.datautils.common; import java.io.Serializable; import java.util.List; ...

  10. 分页插件--根据Bootstrap Paginator改写的js插件

    刚刚出来实习,之前实习的公司有一个分页插件,和后端的数据字典约定好了的,基本上是看不到内部是怎么实现的,新公司是做WPF的,好像对于ASP.NET的东西不多,导师扔了一个小系统给我和另一个同事,指了两 ...

随机推荐

  1. C# .net mvc web api 返回 json 内容,过滤值为null的属性

    在WebApiConfig.Register 中增加一段 #region 过滤值为null的属性 //json 序列化设置 GlobalConfiguration.Configuration.Form ...

  2. Azure CosmosDB (9) Unique Key Constraints

    <Windows Azure Platform 系列文章目录> 在Azure Cosmos DB中,还支持Unique Key Constraints(唯一键约束). 我们可以在Azure ...

  3. Linux运维小知识

    自己日常用到的命令稍微备份一下: 版本确认 CentOS / RedHat Enterprise cat /etc/redhat-release Ubuntu cat /etc/lsb-release ...

  4. cassert(assert.h)——1个

    http://www.cplusplus.com/reference/cassert/assert/ 声明:void assert (int expression); #include <ios ...

  5. xampp启动MySQL出现Error: MySQL shutdown unexpectedly.

    20175227张雪莹 2018-2019-2 <Java程序设计> xampp启动MySQL出现Error: MySQL shutdown unexpectedly. 问题 本周在学习教 ...

  6. 适用于移动设备弹性布局的js脚本(rem单位)

    背景介绍 目前,随着移动设备的普及和4G网络的普及,web在移动端的占比已经远远超过PC端,各种H5页面推广页面,H5小游戏热度火爆.以前简单的使用px单位(没有弹性)的时代已经无法满足各位设计师和用 ...

  7. c#+cad2010+MQ接收消息

    cad2015+版本可以使用TrayItem气泡显示消息 static TrayItem trayItem = new TrayItem(); public static void testtrayi ...

  8. Garbage-Only-One的IO路

    我的任务计划 刷题计划 BZOJ 1.1202 2.1008 3.等等 搜索 1.搜索题单 学习计划 树 1.树状数组or树状数组or树状数组 2.线段树 搜索 1.A*

  9. hive动态分区问题--分区为中文

    报错如下: Loading data to table data_da.tmp_wlw_test partition (stat_date=2017-05-11, business_type_name ...

  10. 通过SQLServer的数据库邮件来发送邮件

    前段时间需要做一个发送邮件的功能,于是就花了一点时间研究了一下.发现通过SQLServer就可以发送邮件,只需要配置一下就可以了,而且配置过程很简单.下面来说一下配置过程: 1.启用Database ...