最初にレンダリングを見てみましょう:
シンプルなページングJSコード:
1。効果説明:
ページネーションなしで表示できるjQueryプラグイン
jQueryページングプラグイン-jquery.page.jsは非常に簡単に使用でき、大きな効果があります
2。通話方法:
$( "。tcdpagecode") PageCount:ページの総数現在:現在のページ
3。JSカプセル化コード
// pagination plugin/** ch **/(function($){var ms = {init:function(obj、args){function(){ms.fillhtml(obj、args); ms.bindevent(obj、args);})(})(); obj.empty(); && args.pagecount!= 4){obj.append( '<a href = ">'+1+ '</a>'); -2、args.current+2; 1){if(start!= args.current){obj.append( '<a href = ">' + start + '</a>'); args.pagecount> 5){obj.append( '<span> ... </span>'); //(args.current <args.pagecount){obj.append( '<a href = "javascript </a>'); }、//バインディングイベントBindevent:function(obj、args){return(function(){obj.on( "click"、 "a.tcdnumber"、function(){var current = parseint($(this).text()); ms.fillhtml(obj、{"" culern ":pagecount":arg.pagecount}; if(args.backfn)== "function"){args.backfn(current)}}}}}( "click"、 "a.prevpage" {var current()parseint(obj.children( "span.current"); Ms.Fillhtml( "current": "pagecount":args.pagecount}); parseint( "span.current")。 }}}); }}} $ .fn.createpage = function(options){var args = $ .extend({pagecount:10、current:1、backfn:function(){}}、options); Ms.Init(This、args); }})(jQuery);4。デモを使用します:
<!doctype html> <html lang = "zh-cn" xmlns = "http://www.w3.org/1999/xhtml"> <head> <heata charset = "utf-8"/> <タイトル>パディング:0;リストスタイル:none;} a {text-decoration:none;} a:hover {text-decoration:none;} .tcdpagecode {padding:15px 20x; text-align:left; color:#ccc;} .tcdpagecode a {inline block; color:#428bcca; display; display;ラインハイト:25px;パディング:0 10px;境界線:1px solid #ddd;マージン:0 2px; Border-radius:4px;垂直整列:中央;} .tcdpagecode a:hover {text-decoration:none; border:1px solid#428bca;} .tcdpagecode span.current { #fff; background-color:#428bca;境界:1PXソリッド#428BCA;ボーダーラジウス:4px;垂直整列:中央;} .tcdpagecode span.disabled {display:inline-block; height:25px; line-height:25px;パディング:0 10px;マージン:0 2px; color:#fffffff; #bfbf; border-radius:4px; vertical-align:middle;} </style> </head> <body> <style> .baidu_ads {width:960px;高さ:90px;位置:絶対;左:50%;下:0;マージン左:-480px;オーバーフロー:hidden;} </style> <div> </div> <span style = "display:none;"> </span> <! - code begin-> <div> </div> <pre> call method:$( "。tcdpagecode")。 PAGECOUNT:ページの総数:現在のページ</pre> </body> <スクリプトsrc = "// www.vevb.com/ajaxjs/jquery.min.js"> </script> <script src = "// www.vevb.com/ajaxjs/jquery.page.js"> </scrip $( "。tcdpagecode")。createpage({pagecount:6、current:1、backfn:function(p){console.log(p);}}); </script> <! - コードパーツエンド - > </html>上記はこの記事に関するものです。JavaScriptを学ぶことができることを誰でも役立つことを願っています。