page_ajax,jQuery simplePage+AJAX plus 分页插件

HTML 代码如下:

simplePage

html,body{ margin:0 auto; text-align:center; }

.main{ font:12px/24px "Microsoft YaHei"; height:1000px; }

#page{ margin:100px auto; width:960px; text-align:center; }

#page a{ text-decoration:none; display:inline-block; height:24px; padding:0 8px; border-radius:3px; background-color:#DEF39E; color:#8CAC2C; text-align:center; margin:0 2px; }

#page a:hover,#page .now{ background-color:#8CAC2C; color:#fff; transition:all .5s ease 0s; }

$(function(){

$.simplePage({

obj : "#page",

nowNum : 1,

allNum : 20,

callBack : function(now, all){

$(".back").html(now + "-" + all);

}

});

});

/*!

* jQuery simple page plus v1.0

* http://t.qq.com/websole

* Author:sole

* Mail:macore@163.com

* Created:2012/10/31

* Copyright 2012 - http://t.qq.com/websole

*/

$.extend({

//obj:分页对象; noeNum:当前页; allNum:总页数; callBack:回调函数

simplePage : function(opt){

if(!opt.obj){ return false; };

var obj = $(opt.obj);

var nowNum = opt.nowNum || 1;

var allNum = opt.allNum || 5;

var callBack = opt.callBack || function(){};

var apd_ele = "";

function ele(num, cls){

var str = "";

if(cls){

str = ""+num+"";

}else{

str = ""+num+"";

}

return str;

}

if(nowNum > 1){

apd_ele = "上一页";

obj.append(apd_ele);

}

if(allNum <= 5){

for(var i=1; i<=allNum; i++){

if(nowNum == i){

apd_ele = ele(i, "now");

}else{

apd_ele = ele(i);

}

obj.append(apd_ele);

}

}else{

for(var i=1; i<=5; i++){

if(nowNum == 1 || nowNum == 2){

if(nowNum == i){

apd_ele = ele(i, "now");

}else{

apd_ele = ele(i);

}

}else if( (allNum - nowNum) == 0 || (allNum - nowNum) == 1 ){

if( (allNum - nowNum) == 0 && i == 5){

apd_ele = ele( (allNum - 5 + i), "now");

}else if( (allNum - nowNum) == 1 && i == 4){

apd_ele = ele( (allNum - 5 + i), "now");

}else{

apd_ele = ele( allNum - 5 + i );

}

}else{

if(i == 3){

apd_ele = ele(nowNum-3+i, "now");

}else{

apd_ele = ele(nowNum-3+i);

}

}

obj.append(apd_ele);

}

}

if((allNum - nowNum) >= 1){

apd_ele = "下一页";

obj.append(apd_ele);

}

callBack(nowNum, allNum);

obj.find("a").click(function(){

var nowNum = parseInt($(this).attr("href").substring(1));

obj.html("");

$.simplePage({

obj : "#page",

nowNum : nowNum,

allNum : allNum,

callBack :callBack

});

return false;

});

}

});

欢迎各位大牛拍砖。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值