Due to project needs, the front-end time needs to display all the attached images under a product in paging. Ajax requests are not considered one by one, so we simply put out all the images at once, and then perform paging when loading. There are many online jquery, property, etc. have all implemented
, but their plug-ins have many ancillary functions that are not needed, and there is no need to reference this library just for such a functional area. Consider it for speed. Of course, it doesn’t matter if your server is good, but In fact, this effect is not necessary, but I think it will be commonly used, so it is packaged into categories for future use and for those who need it to learn and use.
The following is just a simple demo. You can edit the page number style by yourself. There is a default format. No more nonsense, just read it for yourself, there are annotated instructions for use. . . To use the class (3kb), you can refer to the demo. If you don’t understand how to use it, you can leave a message.
In the future, I will slowly write down some common problems encountered in project development, as well as solutions, and share them with everyone.
jpage.js
/* 排序工具 by Funny ZAk <silenceacegmail.com> 2009-8-23 "调用方式 var zp = new zakPage(参数);zp.init(); 参数以此为 源内容容器,分页结果容器,导航容器,页大小,单挑内容回调函数返回li对象,每个li的样式,选择后的样式没有则为null或"" ,默认起始页数,格式化页码显示格式*/ function zakPage(id,pagec,navid,pagesize,lievt,ds,ss,idx,navp){ this.obj = this; this.pageid = id; this.pagec = pagec; this.navc = navid; this.pagesize = pagesize || 7; this.lievt = lievt || null; this.rcount = 0; this.pagecount = 0; this.cpage = 1; this.ds = ds; if(this.ds == null){this.ds = "";} this.ss = ss; if(this.ss == null){this.ss = "";} this.idx = idx; this.navpre = navp || ["共{$pcount}页/{$rcount}条,当前第{cpage}页","首页","上一页","下一页","末页"]; } zakPage.prototype = { init:function(){ document.getElementById(this.pageid).style.display = "none"; this.rcount = document.getElementById(this.pageid).getElementsByTagName("li").length; var residue = this.rcount%this.pagesize; var nums = parseInt(this.rcount/this.pagesize); this.pagecount = nums; if(residue != 0){this.pagecount = nums+1;} this.gopage(this.idx); }, guide:function(){ var nav = document.getElementById(this.navc); var np = this.navpre; nav.innerHTML = np[0].replace("{$rcount}",this.rcount).replace("{$pcount}",this.pagecount).replace("{cpage}",this.cpage); nav.appendChild(this.createa(np[1],1)); nav.appendChild(this.createa(np[2],this.cpage-1)); nav.appendChild(this.createa(np[3],this.cpage+1)); nav.appendChild(this.createa(np[4],this.pagecount)); }, createa:function(html,index){ var aa = document.createElement("a"); aa.innerHTML = html; var o = this.obj; aa.onclick = function(){o.gopage(index);} return aa; }, gopage:function(index){ if(index>this.pagecount){index=1;} if(index<=0){index = this.pagecount;} this.cpage = index; var ghtml = document.getElementById(this.pagec); ghtml.innerHTML = ""; var pages = (index-1)*this.pagesize; var pagee = pages+this.pagesize; if(pagee>this.rcount){pagee = this.rcount;} for(var i=pages;i<pagee;i++){ var lil = document.createElement("li"); lil.className = this.ds; lil.innerHTML = this.litem(i); var sss = this.ss; if(this.lievt !=null){ lil.lievt = this.lievt; lil.onclick = function(){ this.lievt(this); this.className = sss; } } ghtml.appendChild(lil); } this.guide(); }, litem:function(index){ return document.getElementById(this.pageid).getElementsByTagName("li")[index].innerHTML; } }
The following is the complete test code, js has been included
Jpage Demo - by funnyzak
- Php 构造函数construct的前下划线是
- PHP 读取文件内容代码(txt,js等)
- PHP 用数组降低程序的时间复杂度
- PHP 柱状图实现代码
- Ajax+PHP边学边练 之五 图片处理
- PHPMyadmin 配置文件详解(配置)
- 又一个php 分页类实现代码
- php 无限分类的树类代码
- Asp.net 文本框全选的实现
- php zip文件解压类代码
li>各种男女围巾围法图文- photoshop 鼠绘忧郁的少女头像
- Photoshop 一只可爱的卡通小蜜蜂
- Photoshop 调出美女质感的红紫色肤色
- Photoshop 古典的油画效果处理方法
- photoshop 利用滤镜及素材打造超酷的火焰字
- photoshop 鼠绘漂亮的熟睡公主
- Photoshop 华丽的金色宝石皇冠
- Photoshop 粉红色的人物写真图片
- Photoshop 漂亮的紫色人物签名效果
- Photoshop 偏暗的圣诞美女美白
- Photoshop 蓝色梦幻的潮流壁纸制作
- Photoshop调色教程 人物淡灰色质感肤色
- Photoshop 漂亮的圣诞彩球制作
- Photoshop 简单的光照字效果
- HTML/JS互相转换工具-IE7兼容版
- css 在线压缩工具
- CSS整形与最佳化工具[压缩]
- JS Minifier js压缩
- packer_至强的javascript在线加密工具
- XHTML 代码嵌套查看工具[标签闭合]
- 脚本之家 在线进制转换 可以实现各类进制间
- 在线JS脚本校验器检测js错误
- 将html转换为php,javascript和asp的在线工具
- 正则表达式30分钟入门教程
- 正则表达式 基础资料
- javascript 在线参考手册
- vbscript微软官方参考手册
- jQuery入门指南教程
- asp 学习在线手册
- php5最新中文参考手册
- mysql
- sql数据库学习
- 常用广告代码
- 百度近日收录查询
- alexa排名查询
- IP/域名WHOIS
- 网页编辑器
- QQ在线强制聊天工具 加强修正版
- 迅雷 快车专用链接加密解密js代码
- 在线繁简体字转换
- html中文完全手册
- qvod解密工具 马克思