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生 ...
随机推荐
- ubuntu sendmail
一.安装 ubuntu中sendmail函数可以很方便的发送邮件,ubuntu sendmail先要安装两个包. 必需安装的两个包: 代码 sudo apt-get install sendmail ...
- zepto.1.1.6.js源码中的each方法学习笔记
each方法接受要遍历的对象和对应的回调函数作为参数,它的作用是: 1.如果要遍历的对象是类似数组的形式(以该对象的length属性值的类型是否为number类型来判断),那么就把以要遍历的对象为执行 ...
- jQuery源码学习:使用隐藏的new来创建对象
在JQuery源码中发现,JQuery定义一个类,但不用new关键字去创建该类对象,而使用方法调用()方式去创建该对象. 很多时候我们是这样写类,然后使用new创建对象的: function Pers ...
- PHP PSR-3 日志接口规范 (中文版)
日志接口规范 本文制定了日志类库的通用接口规范. 本规范的主要目的,是为了让日志类库以简单通用的方式,通过接收一个 Psr\Log\LoggerInterface 对象,来记录日志信息. 框架以及CM ...
- 安装mysqlsla性能分析工具
开启mysql慢查询日志 vi /etc/my.cnf slow-query-log = on #开启MySQL慢查询功能 slow_query_log_file = /data/mysql/127 ...
- jQuery.data的是jQuery的数据缓存系统
jQuery.Data源码 jQuery.data的是jQuery的数据缓存系统 jQuery.data的是jQuery的数据缓存系统.它的主要作用就是为普通对象或者DOM元素添加数据. 1 内部存储 ...
- sql helper
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.C ...
- eMMC的MMC模式与SPI模式
MMC存贮卡可以分为MMC和SPI两种工作模式,MMC模式是标准的默认模式,具有MMC的全部特性.而SPI模式则是MMC存贮卡可选的第二种模式,这个模式是MMC协议的一个子集,主要用于只需要小数量的卡 ...
- 探索PHP+Nginx(一) 安装Linux操作系统
每次学习一种新的开发语言的时候,都要经历一个很纠结的过程,除非你运气很好或者准备工作充分,否则你在这个过程中总会耗费大量的时间和精力,当然你也会受益很多.而这个过程就是,开发环境的基础搭建,看似是装几 ...
- Graph.js
Graph.js Graph.js A JavaScript library for rendering a graph of nodes