js分页代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head><title>jQuery分页</title><style type="text/css" rel="stylesheet">.page{ display:none;} #pagnation a{ padding-right:5px; } .current { color:blue; } #pagnation{ margin-top:20px; } .numlink,#prev,#next { margin: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; color: rgb(128, 128, 128) !important; background-image: none !important;">#F5F5F5; border: 1px solid #EBEBEB; color: #0072BC; font-weight: normal; margin-left: 10px; padding: 2px 7px; text-decoration: none; width: 22px;; } .current { margin: 0px !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace !important; font-size: 1em !important; color: rgb(128, 128, 128) !important; background-image: none !important;">#DDEEFF; border: 1px solid #BBDDFF; color: #0072BC; cursor: default; margin-left: 10px; padding: 2px 7px; text-decoration: none; } </style></head> <body><div id="content"><div class="page">这里是第一段内容</div><div class="page">这里是第二段内容</div><div class="page">第三段内容</div><div class="page">第四段内容</div><div id="pagnation"></div></div><script type="text/javascript" src="http://www.codefans.net/ajaxjs/jquery1.3.2.js"></script><script type="text/javascript"> var _Pages = $('.page'); var _Nav = $('#pagnation'); function createLinks(){ _Nav.append('<a href="#" id="prev">Prev</a>'); for(var i=0;i<$('.page').length;i++){ _Nav.append('<a href="#" class="numlink">'+(i+1)+'</a>'); } _Nav.append('<a href="#" id="next">Next</a>'); } function process(now,_Prev,_Next){ $('.page:eq('+now+')').css('display','block'); $('.numlink:eq('+now+')').addClass('current'); var total = parseInt($('.page').length - 1); if(now == 0){ _Prev.hide(); _Next.show(); } else if(now == total){ _Prev.show(); _Next.hide(); } else { _Prev.show(); _Next.show(); } } function hideAll(){ _Pages.css('display','none'); $('.numlink').removeClass('current'); } $(document).ready(function(){ //set the first one display none $('.page:eq(0)').css('display','block'); createLinks(); $('.numlink:eq(0)').addClass('current'); var _Next = $('#next'); var _Prev = $('#prev'); var _Link = $('.numlink'); _Prev.hide(); var now = parseInt($('.numlink').index($('.current'))); _Next.click(function(){ hideAll(); process(now+1,_Prev,_Next); now = parseInt($('.numlink').index($('.current'))); }); _Prev.click(function(){ hideAll(); process(now-1,_Prev,_Next); now = parseInt($('.numlink').index($('.current'))); }) _Link.click(function(){ var that = $(this); hideAll(); var which = that.index() - 1; process(which,_Prev,_Next); now = parseInt($('.numlink').index($('.current'))); }) })</script> </body></html></iframe></noscript></object></layer></span></div></table></body></html>js分页代码的更多相关文章
- angular.js分页代码的实例
对于大多数web应用来说显示项目列表是一种很常见的任务.通常情况下,我们的数据会比较多,无法很好地显示在单个页面中.在这种情况下,我们需要把数据以页的方式来展示,同时带有转到上一页和下一页的功能.现在 ...
- 纯js分页代码(简洁实用)
纯js写的分页代码. 复制代码代码如下: //每页显示字数 PageSize=5000; //分页模式 flag=2;//1:根据字数自动分页 2:根据[NextPage]分页 //默认页 start ...
- Angular.js分页代码
$scope.reloadList=function(){ $scope.findPage( $scope.pagina ...
- 非常不错的一个JS分页效果代码
这里分享一个不错的js分页代码. 代码中cpage是页面计数,应为全局变量,可以随处调用它: totalpage是总页数. 与asp分页代码很类似,也是先取得记录总数,然后实现分页,基本的分页思路与原 ...
- 自己封装的JS分页功能[用于搭配后台使用]
* 2016.7.03 修复bug,优化代码逻辑 * 2016.5.25 修复如果找不到目标对象的错误抛出. * 2016.5.11 修复当实际页数(pageNumber)小于生成的页码间隔数时的bu ...
- jsp、js分页功能的简单总结
一.概述 首先,我们要明确为何需要分页技术,主要原因有以下: 1.分页可以提高客户体验度,适当地选择合适的数据条数,让页面显得更有条理,使得用户体验感良好,避免过多数据的冗余. 2.提高性能的需要.分 ...
- 面向对象版js分页
基于前一个js分页,我将代码改成一个面向对象版的js分页,代码如下 http://peng666.github.io/blogs/pageobj <!DOCTYPE html> <h ...
- 浅谈js分页的几种方法
一个项目中必然会遇到分页这种需求的,分页可以使数据加载更合理,也让页面显示更美观,更有层次感!那么js分页到底如何实现呢?下面我就来讲一下三种循序渐进的方法 1.自己纯手写分页 更深入的去理解分页的意 ...
- JAVAEE——BOS物流项目05:OCUpload、POI、pinyin4J、重构分页代码、分区添加、combobox
1 学习计划 1.实现区域导入功能 n OCUpload一键上传插件使用 n 将文件上传到Action n POI简介 n 使用POI解析Excel文件 n 完成数据库操作 n 使用pinyin4J生 ...
随机推荐
- < meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />的作用
< meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" /> 介绍:这 ...
- PHP API反射实例
*反射是操纵面向对象范型中元模型的API,其功能十分强大,可帮助我们构建复杂,可扩展的应用.其用途如:自动加载插件,自动生成文档,甚至可用来扩充PHP语言.php反射api由若干类组成,可帮助我们用来 ...
- [转]MySQL 5.6 全局事务 ID(GTID)实现原理(二)
原文连接:http://qing.blog.sina.com.cn/1757661907/68c3cad333002qsk.html 原文作者:淘长源 转载注明以上信息 前文 MySQL 5.6 全局 ...
- 伪静态(URL重写)
伪静态在可以使用数据库提供更强大的功能的同时,将很长很复杂的链接变成简短的静态链接形式,迎合搜索引擎方便搜索引擎蜘蛛(Spider)来抓取网页上的相关内容,提高页面被搜索引擎索引收录的比率,为用户提供 ...
- 管理Activity,随时随地控制Activity的销毁工作
public class ActivityManager { public static List<Activity> activityList = new ArrayList<Ac ...
- linux source命令学习
1. linux source命令的作用? 我们可能经常需要修改到诸如/etc/profile,~/.bash_profile等这样的配置文件, 一方面我们希望所作的修改在当前的环境中立即生效: 另一 ...
- jQuery判断元素是否是隐藏的代码
if($("#elem_id").is(":hidden")) { } 实例代码1: 复制代码 代码如下: <!DOCTYPE HTML PUBLIC & ...
- 总结FormsAuthentication的使用
一.先看一下使用FormsAuthentication做登录认证的用法 用法一: FormsAuthentication.SetAuthCookie(username, isPersistent); ...
- iOS 7 改变Status Bar 颜色
Set the UIViewControllerBasedStatusBarAppearance to NO in the Info.plist. In ViewDidLoad method or a ...
- sql语句收集
一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份sql server--- 创建 备 ...