js分页--存储数据并进行分页

  //分页方法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();}
)

 

转载于:https://www.cnblogs.com/elves/p/3612855.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/407989.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

c/c++面试试题(一)

1.求下面函数的返回值&#xff08;微软&#xff09;int func(x) { int countx 0; while(x) { countx ; x x&(x-1); } return countx; } 假定x 9999。 答案&#xff1a;8思路&#xff1a;将x转化为2进制&#xff0c;看含有的1…

react(78)--vs打开setting.json

1.ctrl shift p 2.输入setting 3.找到这一项

stdspan ---C++20

std::span —C20 std::span的定义 template<class T,std::size_t Extent std::dynamic_extent > class span;std::span是指向一组连续的对象的对象, 是一个视图view, 不是一个拥有者owner 一组连续的对象可以是 C 数组, 带着大小的指针, std::array, 或者 std::strin…

2. Get the codes from GIT

Clone the code from git. Click the “GitEx Clone”. Paste the url into the “Repository to clone”. You can get the route from git repository from it: https://msstash.companydomainname.com/ .Find the project which you want to download and then click the “…

按钮控件数组

Public Class ButtonArray Inherits System.Collections.CollectionBase Private ReadOnly HostForm As System.Windows.Forms.Form 创建类的构造函数。 Visual Basic Public Sub New(ByVal host As System.Windows.Forms.Form) HostForm host Me.Add…

c/c++面试试题(二)

21. New delete 与malloc free 的联系与区别?答案&#xff1a;都是在堆(heap)上进行动态的内存操作。用malloc函数需要指定内存分配的字节数并且不能初始化对象&#xff0c;new 会自动调用对象的构造函数。delete 会调用对象的destructor&#xff0c;而free 不会调用对象的des…

The Ranges Library (2) --- C++20

The Ranges Library (2) — C20 比较std与std::ranges算法 比较一下std::sort和std::ranges::sort std::sort template< class RandomIt > constexpr void sort( RandomIt first, RandomIt last );template< class ExecutionPolicy, class RandomIt > void sor…

react(79)--ant design确认框

<Popconfirmplacement"rightBottom"title{text}onConfirm{confirm}okText"Yes"cancelText"No"><Button>RB</Button></Popconfirm>

程序中的得与失

俗话说&#xff0c;舍得&#xff0c;有舍便有得&#xff0c;程序或许和世间万物一个样&#xff0c;讲究阴阳平衡。或许您写程序过程中&#xff0c;得到一颗歪脖树&#xff0c;却放弃了一大片大森林&#xff0c;能正确的取舍矛盾体双方的关系&#xff0c;或许是您扎实功底的体现…

[转]新东方老师上课讲的笑话(太有才了)

[张洪伟] 起名字的问题&#xff1a;中西方都不愿意以鲜花、野草起名字&#xff0c;什么牡丹玫瑰&#xff0c;小红小翠了&#xff0c;一听就变味了&#xff1b;张建、李建&#xff0c;但不能叫范建&#xff08;贱&#xff09;了&#xff1b;北京以前有个建&#xff08;贱&#x…

c/c++面试试题(三)

慧通&#xff1a; 什么是预编译何时需要预编译&#xff1a;&#xff11;、总是使用不经常改动的大型代码体。 &#xff12;、程序由多个模块组成&#xff0c;所有模块都使用一组标准的包含文件和相同的编译选项。在这种情况下&#xff0c;可以将所有包含文件预编译为一个预编译…

mysql安装使用--2 用户管理

1 修改mysql.user表 添加用户 mysql> INSERT INTO mysql.user (Host,User,Password) VALUES (\%\,\system\, PASSWORD(\manager\)); mysql> FLUSH PRIVILEGES 2 create 和 grant命令省略 3 user表内容 MySQL用户名由两部分组成&#xff1a;(user, host)&#xff0c;二者…

constexpr if --- C++ 20

constexpr if — C 20 constexpr if 可以让我们实现条件编译 template <typename T> auto getResult(T t) {if constexpr (std::is_integral_v<T>)return *t;elsereturn t; }如果T是intergral类型,执行第一个分支,否则执行第二个分支 还记得前文写过的模板元编程…

WPF中的动画

WPF中的动画 周银辉动画无疑是WPF中最吸引人的特色之一&#xff0c;其可以像Flash一样平滑地播放并与程序逻辑进行很好的交互。这里我们讨论一下故事板。在WPF中我们采用Storyboard&#xf…

c/c++面试试题(四)

華為1、局部变量能否和全局变量重名&#xff1f;答&#xff1a;能&#xff0c;局部会屏蔽全局。要用全局变量&#xff0c;需要使用"::"局部变量可以与全局变量同名&#xff0c;在函数内引用这个变量时&#xff0c;会用到同名的局部变量&#xff0c;而不会用到全局变量…

[访问系统] Api_Win32_Mac类工具包 (转载)

点击下载 Api_Win32_Mac.zip using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices;namespace BaseFunction {class API{[DllImport("kernel32")]//内存public static extern void GlobalM…

constexpr 函数

constexpr 函数 — C 20 constexpr double pi 3.14;constexpr允许你在编译时使用典型的C函数语法进行编程,但这并不意味之constexpr只和编译期有关 constexpr函数可以在编译期运行,也可以在运行时运行 但在以下情况constexpr函数必须在编译期运行: constexpr函数在编译的上…

react(82)--方法写在effects里面

effects: {*addOrUpdateAssistActivity({ payload, callback }, { call }) {try {const res yield call(addOrUpdateAssistActivity, payload);if (callback && typeof callback function) {yield callback(res);}} catch (error) {console.log(error);}},