自編基於jQuery實現分頁外掛程式

2022-02-02 10:38:20 字數 3692 閱讀 4142

$(function

());/**

* @params pagesize:每頁顯示資料條數

* @params currentpage:當前頁碼

* @params data:查詢時的資料[json格式]

* @params pageshowdivid:顯示分頁內容的div的id屬性值

* @params contentmark:內容資訊標記

* @params pageskin:分頁顯示**

* @params styletype:模板種類[2種可選,1|2]

* @function custommethod():使用者自定義函式,用於給分頁中加入使用者特有內容

* ljm

*/$.extend(

var reg = /^[0-9]*$/;

//對currentpage屬性設定預設初始值

if(options['currentpage']==""||options['currentpage']<=0||options['currentpage']==null||!reg.test(parseint(options['currentpage'])))

//對pagesize屬性設定預設初始值

if(options['pagesize']==null||options['pagesize']==""||!reg.test(parseint(options['pagesize'])))

//對contentmark屬性設定預設初始值

if(options['contentmark']==null||options['contentmark']=="")

//對pageskin屬性設定預設初始值

if(options['pageskin']==null||options['pageskin']=="")

//對styletype屬性設定預設初始值

if(options['styletype']==null||options['styletype']==""||options['styletype']>2||!reg.test(parseint(options['styletype'])))

//請求資料

$.ajax(,

type:'post',

async:

false

, cache:

false

, datatype:'json',

success:

function

(data)

//if(jquery.isfunction(custommethod))

}

//對於總數部分做處理[分頁效果展示]

if(null!=data[0].count)

else

//if(number(currentpage)else

//新增自定義跳轉按鈕

//新增css樣式[1:引用模板1的樣式]

$.cssstyle(options['pageshowdivid'],options['pageskin'],1);

}else

else

//顯示的頁碼數

var numofpages = 10;

//當前頁前面的頁數

var prevpages = (parseint(currentpage)-4)>0?4:(parseint(currentpage)-1);

//當前頁後面的頁數

var nextpages = (parseint(prevpages)+5)==9?5:(parseint(numofpages)-parseint(prevpages)-1);

//對於總頁數小於10頁的情況下進行prevpages與nextpages控制

if(parseint(pagenum)if(parseint(currentpage)+parseint(nextpages)>parseint(pagenum)&&parseint(pagenum)>=parseint(numofpages))

//當前頁碼前面的頁碼數顯示

for(var i=parseint(currentpage)-parseint(prevpages);i)

//當前頁碼後面的頁碼數顯示

for(var i=currentpage;i<=parseint(currentpage)+parseint(nextpages);i++)

else

}//if(currentpageelse

//新增自定義跳轉按鈕

//新增css樣式[2:引用模板2的樣式]

$.cssstyle(options['pageshowdivid'],options['pageskin'],2);}}

},error:

function

() });

}, cssstyle:

function

(obj,pageskin,type));

$("#"+obj).find("span").css();

$("#"+obj).find("a").css();

$("#"+obj).find("input[type='text']").css();

$("#"+obj).find("input[type='button']").css();

$("#"+obj).find("a").mouseover(function

(e));

});$("#"+obj).find("a").mouseout(function

(e));

});}

else

if(type==2));

$("#"+obj).find("span[class='pagecommon']").css();

$("#"+obj).find("span[class='pageactive']").css();

$("#"+obj).find("input[type='text']").css();

$("#"+obj).find("input[type='button']").css();

$("#"+obj).find("span[class='pagecommon']").mouseover(function

());

});$("#"+obj).find("span[class='pagecommon']").mouseout(function

());

});}

},checkinputnum:

function

(obj,pagenum)

if(parseint(page)<=0||parseint(page)>parseint(pagenum))

$("#simopepagebtn").attr("canclick",'true');

},turntopage:

function

(obj,options,pagenum)

var pageno = $("#simopepagetxt").val();

if(parseint(pageno)<=0||parseint(pageno)>parseint(pagenum))

else

); }

}});

我們都過分崇拜別人的**,那是因為你在看不在寫!!!

jquery實現簡單分頁

這裡我的分頁思路是先建立乙個拼接行函式,然後根據每頁的行數,將陣列再放到分頁函式裡進行分頁。新增行函式 index 預設頁碼 num 一頁的行數 一頁的資料數 list 要拼成tr的資料list function init index,num,list else 分頁函式 function page...

JQuery實現table分頁

1.直接貼 var pagesize 2 每頁顯示的記錄條數 var curpage 0 顯示第curpage頁 var len 總行數var page 總頁數 function else displaypage lastpage click function else displaypage fu...

基於Jquery Ajax Json實現分頁顯示

1.後台action產生json資料。list blacklist blackservice.getblackinfolist mobilenum,gatewayid,startdate,enddate int totalrows blacklist.size stringbuffer sb new...