//分页方法
var page = function(){
this.v = {
o:null,//ul父级层
home:null,
previous:null,
next:null,
last:null,
list:[],
pageSize:10,
pageIndex:0,
pageCount:0,
rowCount:0
};
this.init = function(){
var _this = this;
_this.v.o.find("li").each(function(i,o){
_this.v.list.push($(o).html());
}); _this.v.rowCount = _this.v.list.length;
_this.v.pageCount = parseInt((_this.v.rowCount + _this.v.pageSize - 1)/_this.v.pageSize);
_this.process(0); _this.addcolor([_this.v.home,_this.v.previous]); //首页
_this.v.home.click(function(){
_this.v.pageIndex = 0;
_this.process(_this.v.pageIndex);
_this.addcolor([_this.v.home,_this.v.previous]);
_this.removecolor([_this.v.next,_this.v.last]); });
//上一页
_this.v.previous.click(function(){
if(_this.v.pageIndex > 0){
_this.process(--_this.v.pageIndex); if(_this.v.pageIndex == 0)
_this.addcolor([_this.v.home,_this.v.previous]); _this.removecolor([_this.v.next,_this.v.last]);
}
});
//下一页
_this.v.next.click(function(){
if(_this.v.pageIndex < _this.v.pageCount-1){
_this.process(++_this.v.pageIndex); if(_this.v.pageIndex == _this.v.pageCount-1)
_this.addcolor([_this.v.next,_this.v.last]); _this.removecolor([_this.v.home,_this.v.previous]);
}
});
//尾页
_this.v.last.click(function(){
_this.v.pageIndex = _this.v.pageCount-1;
_this.process(_this.v.pageIndex); _this.addcolor([_this.v.next,_this.v.last]);
_this.removecolor([_this.v.home,_this.v.previous]);
});
};
this.process = function(n){
var _this = this;
_this.v.o.find("ul").empty();
for(var i=(n*_this.v.pageSize);i<_this.v.rowCount;i++){
if(i > 0 && i % (_this.v.pageSize*(n+1)) == 0){
break;
}
_this.v.o.find("ul").append("<li>"+_this.v.list[i]+"</li>");
}
}
this.addcolor = function(ac){
for(var j=0;j<ac.length;j++)
ac[j].addClass("page_disabled");
}
this.removecolor = function(rc){
for(var j=0;j<rc.length;j++)
rc[j].removeClass("page_disabled");
}
}; (function(){
//初始化按钮
var p1 = new page();
p1.v.o = $("#marquees1");
p1.v.home = $("#zb1");
p1.v.previous = $("#zb2");
p1.v.next = $("#zb3");
p1.v.last = $("#zb4");
p1.init();
}
)

js分页--存储数据并进行分页的更多相关文章

  1. vue+mock.js+element-ui模拟数据搞定分页

    效果如图: 前提是搭好vue前端框架,npm install mockjs引入mock.js 当前页全部代码如下,其他有关element-ui的引入未提到,仅作参考用 <!-- 用户管理 --& ...

  2. 腾讯云图片鉴黄集成到C# SQL Server 怎么在分页获取数据的同时获取到总记录数 sqlserver 操作数据表语句模板 .NET MVC后台发送post请求 百度api查询多个地址的经纬度的问题 try{}里有一个 return 语句,那么紧跟在这个 try 后的 finally {}里的 code 会 不会被执行,什么时候被执行,在 return 前还是后? js获取某个日期

    腾讯云图片鉴黄集成到C#   官方文档:https://cloud.tencent.com/document/product/641/12422 请求官方API及签名的生成代码如下: public c ...

  3. 抓取Js动态生成数据且以滚动页面方式分页的网页

    代码也可以从我的开源项目HtmlExtractor中获取. 当我们在进行数据抓取的时候,如果目标网站是以Js的方式动态生成数据且以滚动页面的方式进行分页,那么我们该如何抓取呢? 如类似今日头条这样的网 ...

  4. scroll pagination.js数据重复加载、分页问题

    scroll pagination.js数据重复加载.分页问题 解决办法 参考资料: http://blog.csdn.net/dyw442500150/article/details/1753242 ...

  5. easyui-datagrid连接数据库实现分页查询数据

    一.利用MVC思想建立底层数据库: package com.hanqi.dao; import java.util.ArrayList; import java.util.List; import o ...

  6. 【原创】10万条数据采用存储过程分页实现(Mvc+Dapper+存储过程)

    有时候大数据量进行查询操作的时候,查询速度很大强度上可以影响用户体验,因此自己简单写了一个demo,简单总结记录一下: 技术:Mvc4+Dapper+Dapper扩展+Sqlserver 目前主要实现 ...

  7. vuejs实现本地数据的筛选分页

    今天项目需要一份根据本地数据的筛选分页功能,好吧,本来以为很简单,网上搜了搜全是ajax获取的数据,这不符合要求啊,修改起来太费力气,还不如我自己去写,不多说直接上代码 效果图: 项目需要:点击左侧进 ...

  8. redis分页获取数据

    php代码: 采用哈希类型存储数据,有序集合存储分页数据,进行倒序与正序的排序. $getGoodsInfo = M('goods_test')->select(); for($i=0;$i&l ...

  9. vue.js 2.0实现的简单分页

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title&g ...

随机推荐

  1. React Native 开发之 (07) 常用组件-View

    掌握了React Native的组件就可以使用IOS的原生组件和API. 一 View组件 就像开发web应用程序中,需要使用很多的HTML标签.例如 div,form.但是在基于DIV+CSS布局的 ...

  2. python从Microsoft Excel文件中导入数据

    excel中后缀为csv和xls,二者区别如下:1.xls 文件就是Microsoft excel电子表格的文件格式.2.csv是最通用的一种文件格式,它可以非常容易地被导入各种PC表格及数据库中. ...

  3. JavaWeb---总结(五)Http协议

    一.什么是HTTP协议 HTTP是hypertext transfer protocol(超文本传输协议)的简写,它是TCP/IP协议的一个应用层协议,用于定义WEB浏览器与WEB服务器之间交换数据的 ...

  4. 简单的angular表单验证指令

    <html ng-app="myApp"> <head> <meta charset="UTF-8"> <title& ...

  5. WinForm------PopupMenu控件的使用

    转载: http://www.cnblogs.com/xlx0210/archive/2010/07/14/1777366.html

  6. 使用node的插件UglifyJs来合并和压缩文件

    code: var fs = require('fs'); var jsp = require("./UglifyJS-master/uglify-js").parser; var ...

  7. Unity State Machine

    https://unity3d.com/learn/tutorials/modules/beginner/5-pre-order-beta/state-machine-behaviours http: ...

  8. Red Black Tree in C

    http://web.mit.edu/~emin/www.old/source_code/red_black_tree/index.html

  9. Visual Studio 2012优化

    http://msdn.microsoft.com/en-us/library/ms182372.aspx

  10. EditPlus开发Python的简单设置

    EditPlus是一个功能强大的编辑器,这里介绍用它来开发Python程序所需要的简单设置. 环境:win7 1.设置Python语法缩进: [1]工具-->设置用户自定义工具 [2]在分类面板 ...