`
- 浏览:
78098 次
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>jquery分页控件</title>
<script src="jquery-1.3.min.js" type="text/javascript"></script>
</head>
<body>
<div class="pager"></div>
<!--<div>
<select class="SEID">
<option>10</option>
<option selected="selected" >20</option>
<option>30</option>
</select>
<div class="first">首页</div>
<div class="pre">上一页</div>
<div class="centerclass"></div>
<div class="next">下一页</div>
<div class="last">最后一页</div>
<input type="text" value="1" /> of<span class="totelspan">0</span>
</div>-->
</body>
</html>
<script type="text/javascript">
var pageindex=1;
var totelsize=60;
var centersize=5;
var pagesize=0;
var totelSec=0;
var outStr="";
var se="<select class=\"SEID\">"
+"<option>5</option>"
+"<option selected=\"selected\" >10</option>"
+"<option>15</option>"
+"</select>";
var firstdiv="<div class=\"first\">首页</div>";
var prediv="<div class=\"pre\">上一页</div>";
var centerdiv="<div class=\"centerclass\"></div>";
var nextdiv="<div class=\"next\">下一页</div>";
var lastdiv="<div class=\"last\">最后一页</div>";
$('.pager').empty();
$('.pager').append(se)
$('.pager').append(firstdiv)
$('.pager').append(prediv)
$('.pager').append(centerdiv)
$('.pager').append(nextdiv)
$('.pager').append(lastdiv)
function PageInit()
{
var size=0;
var barObj=this;
var PageReinit=function()
{
pagesize=$(".SEID option:selected")[0].innerText;
size=parseInt(totelsize/pagesize)
var lastSize=totelsize%pagesize;//最后一页显示记录
if(lastSize>0)
{
size=size+1;
}
totelSec=parseInt(size/centersize);
var leftSize=size%centersize;//最后一个区段的显示记录
if(leftSize>0)
{
totelSec =totelSec+1;
}
PageBarinit();
}
var reSetPage=function()
{
pageindex=1;
pagesize=0;
totelSec=0;
outStr="";
}
// alert('总页数:'+size)
// alert('总区段:'+totelSec)
// alert('每页记录数:'+pagesize);
var SeClick=function(e)
{
var Selectindex=e.target[e.target.selectedIndex].innerText;
pagesize=parseInt(Selectindex);
alert('每页显示:'+Selectindex);
reSetPage();
PageReinit();
}
var firstClick=function(e)
{
alert('点击到首页');
if(pageindex!=1)
{
pageindex=1;
alert('到了第1页');
}
}
var preClick=function(e)
{
alert('点击到上一页');
if(pageindex!=1)
{
pageindex =pageindex-1;
alert('到了第'+pageindex+'页');
}
ChangeCenterBar(pageindex+1);
}
var pageClick=function(e)
{
var targePage=parseInt(e.target.innerText);
pageindex=targePage;
alert('点击了第'+targePage+"页");
ChangeCenterBar(targePage);
}
var nextClick=function(e)
{
alert('点击了下一页');
if(pageindex<size)
{
pageindex =pageindex+1;
if(pageindex==size)
{
alert('到了最后一页');
}
else{
alert('到了第'+pageindex+'页');
}
}
ChangeCenterBar(pageindex-1);
}
var lastClick=function(e)
{
alert('点击了最后一页');
if(pageindex<size)
{
pageindex=size;
alert('到了第'+size+'页');
}
}
var ChangeCenterBar=function(CurrentIndex)
{
var currentSec=parseInt(CurrentIndex/centersize);
if( CurrentIndex%centersize==1)
{
if(currentSec<totelSec)
{ PageBarinit();}
}
if(CurrentIndex%centersize==0)
{
var currentSec=parseInt(CurrentIndex/centersize);
if(currentSec<totelSec)
{ PageBarinit();}
}
}
var PageBarinit=function()
{
$('.SEID').unbind('change',SeClick);
$('.first').unbind('click',firstClick);
$('.pre').unbind('click',preClick);
$('.next').unbind('click',nextClick);
$('.last').unbind('click',lastClick);
$('.SEID').bind('change',SeClick);
$('.first').bind('click',firstClick);
$('.pre').bind('click',preClick);
$('.next').bind('click',nextClick);
$('.last').bind('click',lastClick);
if(size<=centersize)
{
$('.centerclass').empty();
for(var i=1;i<=size;i++)
{
var cdiv="<span id='Page_"+String(i)+"'>"+i+"</span>";
$('.centerclass').append(cdiv);
$("#Page_"+i).bind('click',pageClick);
}
}else if(size>centersize)
{
$('.centerclass').empty();
if( pageindex%centersize==0)
{
var currentSec=parseInt(pageindex/centersize);//当前区段
if(currentSec<totelSec)
{
// alert(9)
var startIndex=(currentSec-1)*centersize+1;
for(startIndex;startIndex<=currentSec*centersize;startIndex++)
{
//alert(startIndex)
//alert('最大'+currentSec*centersize);
var cdiv="<span id='Page_"+String(startIndex)+"'>"+startIndex+"</span>";
$('.centerclass').append(cdiv);
$("#Page_"+startIndex).bind('click',pageClick);
}
}
else if(currentSec==totelSec)
{
var startIndex=(currentSec-1)*centersize+1;
for(startIndex;startIndex<=currentSec*centersize;startIndex++)
{
var cdiv="<span id='Page_"+String(startIndex)+"'>"+startIndex+"</span>";
$('.centerclass').append(cdiv);
$("#Page_"+startIndex).bind('click',pageClick);
}
}else{
alert('分页出错');
}
}else if(pageindex%centersize>0)
{
var currentSec=parseInt(pageindex/centersize)+1;//当前区段
if(currentSec<totelSec)
{
var startIndex=(currentSec-1)*centersize+1;
for(startIndex;startIndex<=((currentSec-1)*centersize+centersize);startIndex++)
{
var cdiv="<span id='Page_"+String(startIndex)+"'>"+startIndex+"</span>";
$('.centerclass').append(cdiv);
$("#Page_"+startIndex).bind('click',pageClick);
}
}
else if(currentSec==totelSec){
var startIndex=(currentSec-1)*centersize+1;
for(startIndex;startIndex<=((currentSec-1)*centersize +size%centersize);startIndex++)
{
var cdiv="<span id='Page_"+String(startIndex)+"'>"+startIndex+"</span>";
$('.centerclass').append(cdiv);
$("#Page_"+startIndex).bind('click',pageClick);
}
}else
{
alert('分页出错');
}
}
}
}
PageReinit();
}
PageInit();
</script>
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
**jQuery分页控件**是前端开发中常用的一种组件,它能够帮助用户高效地浏览大量数据,提升用户体验。在网页应用中,如果一次性加载所有数据可能会导致页面响应速度变慢,甚至消耗过多的网络资源。因此,使用分页控件...
这个JQuery分页控件正是利用了JQuery的便利性,通过简单的配置和调用,即可快速实现分页功能。它的主要特点包括: 1. **跨语言支持**:由于它是基于JavaScript的,因此可以无缝地与各种服务器端技术如PHP、ASP.NET...
jQuery分页控件是一种用于处理大量数据并分批次显示的交互组件,它简化了前端开发者的工作,通过简单的API调用就能实现强大的分页功能。在这个项目中,我们看到的"jquery分页控件.rar"包含了运行一个基本分页控件所...
总的来说,"ajax+jquery分页控件(asp.net)"涉及到前端和后端的联合工作,利用jQuery的Ajax功能发送异步请求到服务器获取分页数据,同时在后端处理这些请求并返回必要的数据。然后,前端使用这些数据更新页面的显示,...
jQuery分页控件是基于jQuery构建的一种用于实现网页数据分页显示的工具。这种控件通常包含前后翻页按钮、页码选择器以及当前页数和总页数的显示,帮助用户轻松浏览大量数据。 实现jQuery分页控件的基本步骤如下: ...
综上所述,jQuery分页控件是一个实用的前端组件,通过JavaScript和jQuery的结合,可以轻松实现数据分页,提高网页的交互性和性能。对于前端开发者来说,理解和掌握这种控件的实现原理和使用方法,对于提升项目质量和...
在Web开发中,分页控件...总的来说,这个简单的分页控件代码可以帮助开发者快速理解分页的基本原理,为进一步的Web开发打下基础。如果你正在学习前端开发或者需要自己动手实现分页功能,这个项目是一个不错的实践案例。
本教程将详细介绍如何使用jQuery分页插件与JavaServer Pages(JSP)结合,实现一个高效的分页功能。我们将重点讨论jQuery分页插件jPagination的使用方法,以及它与JSP的集成。 首先,`jQuery`是一种轻量级的...
《基于jQuery实现简单的分页控件》 在网页开发中,分页功能是常见的数据展示方式,尤其是在数据量较大的情况下,它可以有效地组织信息,提高用户体验。这篇文章主要介绍如何使用jQuery来实现一个简单易用的分页控件...
在本篇文章中,我们将深入探讨分页控件的概念、功能、设计原则以及在不同编程语言和框架中的实现。 1. 分页控件概念: 分页控件通常由一系列数字按钮组成,代表不同的页面,以及前进和后退箭头,允许用户在多个页面...
本压缩包中的“C#超级好用的分页控件v0.1源码”可能是实现以上某一种或多种方式的一个实现,具体实现细节需要查看源代码才能了解。通常,这样的控件会包含以下几个关键部分: - 数据查询逻辑:根据当前页数和每页...
jQuery分页插件jPagination是Web开发中一个非常实用的工具,它可以帮助开发者轻松地在大量数据中实现分页功能,提升用户体验。jPagination利用了jQuery的强大功能,以简洁的API设计,使得分页功能的集成变得简单易行...
总的来说,基于jQuery的JS+Ajax分页控件通过结合JavaScript和服务器API,实现了无需刷新页面即可动态加载数据的分页功能。这既提高了性能,又提升了用户体验。开发者可以根据实际需求进行定制和扩展,比如增加翻页...
`aspnetpager.dll`是一个专为ASP.NET平台设计的分页控件,它能帮助开发者轻松实现高效、易用的分页效果。本文将详细介绍这个控件的使用方法和关键特性。 ### 一、分页控件概述 分页控件是网页设计中用于处理大量...
在描述中提到的"JQuery autocomplete ajax分页",意味着这个实现增加了分页功能。分页是处理大量数据的常用方法,它可以将数据分成多个部分,每次只加载一部分到前端,这样可以减少一次性加载所有数据带来的性能问题...