成人精品一区二区三区中文字幕-成人精品一区二区三区-成人精品一级毛片-成人精品亚洲-日本在线视频一区二区-日本在线视频免费

導航首頁 ? 技術教程 ? 使用JQuery實現的分頁插件分享
全站頭部文字 我要出現在這里
使用JQuery實現的分頁插件分享 605 2024-03-22   

一個簡單的jQuery分頁插件,兼容AMD規范和requireJS.

/**
 * jQuery分頁插件
 * */
;(function (factory) {
  if (typeof define === "function" && define.amd) {
    // AMD模式
    define([ "jquery" ], factory);
  } else {
    // 全局模式
    factory(jQuery);
  }
}(function ($) {
   
   //定義MyPagePlugin的構造函數
  MyPagePlugin = function(ele, option) {
     //  this.viewHtml="<nav><ul class='pagination'><li><a id='firstPageli'>«</a></li><li><a id='prevPageli'>‹</a></li><li class='active'><a>第<span id='curPageNoSpan'></span>頁,共<span id='allPageCountSpan'></span>頁</a></li><li><a id='nextPageli'>›</a></li><li><a id='lastPageli'>»</a></li></ul></nav>";
  this.viewHtml= "<div class='pageplugin'><a class='first firstPageli'>«</a><a class='previous prevPageli'>‹</a><a class='present'>第<span class='curPageNoSpan'></span>頁,共<span class='allPageCountSpan'></span>頁</a><a class='next nextPageli'>›</a><a class='last lastPageli'>»</a></div>"
 
    this.$element = ele;
    /**參數:page:當前頁,pageCount:總共頁數,onPaged回調函數,回調函數會傳入頁數*/
    this.defaults = {
      page:1,
      pageCount:1,
      onPaged:function(pageNo){}
    };
    this.options = $.extend({}, this.defaults, option);
 
  }
  //定義MyPagePlugin的方法
  MyPagePlugin.prototype = {
    initPlugin:function(){
      this.$element.empty();
       this.$element.append(this.viewHtml);
       this.options.onPaged(this.options.page);//初始化
       this.$element.find(".curPageNoSpan").text(this.options.page);
       this.$element.find(".curPageNoSpan").data("options",this.options);
       this.$element.find(".allPageCountSpan").text(this.options.pageCount);
       this.$element.find(".firstPageli").on("click",function(e){
         
        var curNo=$(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").text();
        curNo=parseInt(curNo);
        if(curNo==1){
           return false;
        }else{
           
          $(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").data("options").onPaged(1);
          $(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").text(1);
        }
        return false;
       });
       this.$element.find(".prevPageli").on("click",function(e){
        var curNo=$(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").text();
        curNo=parseInt(curNo);
        if(curNo==1){
          return false;
        }else{
          $(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").data("options").onPaged(curNo-1);
          $(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").text(curNo-1);
        }
        return false;
       });
       this.$element.find(".nextPageli").on("click",function(e){
        var curNo=$(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").text();
        curNo=parseInt(curNo);
        var pageCount=$(e.currentTarget).parent("div.pageplugin").find(".allPageCountSpan").text();
        pageCount=parseInt(pageCount);
        if(curNo==pageCount){
          return false;
        }else{
          $(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").data("options").onPaged(curNo+1);
          $(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").text(curNo+1);
        }
        return false;
       });
       this.$element.find(".lastPageli").on("click",function(e){
        var curNo=$(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").text();
        curNo=parseInt(curNo);
        var pageCount=$(e.currentTarget).parent("div.pageplugin").find(".allPageCountSpan").text();
        pageCount=parseInt(pageCount);
        if(curNo==pageCount){
           return false;
        }else{
          $(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").data("options").onPaged(pageCount);
          $(e.currentTarget).parent("div.pageplugin").find(".curPageNoSpan").text(pageCount);
        }
        return false;
       });
       
    }
 
 
  }
  $.fn.pagePlugin = function (option) {
    var pagePlugin=new MyPagePlugin(this,option);
    pagePlugin.initPlugin();
  };
}));

CSS

.pageplugin {
 display: inline-block;
 border: 1px solid #CDCDCD;
 border-radius: 3px; }
 
.pageplugin a {
 cursor: pointer;
 display: block;
 float: left;
 width: 20px;
 height: 20px;
 outline: none;
 border-right: 1px solid #CDCDCD;
 border-left: 1px solid #CDCDCD;
 color: #767676;
 vertical-align: middle;
 text-align: center;
 text-decoration: none;
 font-weight: bold;
 font-size: 16px;
 font-family: Times, 'Times New Roman', Georgia, Palatino;
  background-color: #f7f7f7;
 /* ATTN: need a better font stack 
 background-color: #f7f7f7;
 background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f3f3f3), color-stop(100%, lightgrey));
 background-image: -webkit-linear-gradient(#f3f3f3, lightgrey);
 background-image: linear-gradient(#f3f3f3, lightgrey); */}
 .pageplugin a:hover, .pageplugin a:focus, .pageplugin a:active {
  color:#0099CC;
  background-color: #cecece;
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #e4e4e4), color-stop(100%, #cecece));
  background-image: -webkit-linear-gradient(#e4e4e4, #cecece);
  background-image: linear-gradient(#e4e4e4, #cecece); }
 .pageplugin a.disabled, .pageplugin a.disabled:hover, .pageplugin a.disabled:focus, .pageplugin a.disabled:active {
  background-color: #f3f3f3;
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f3f3f3), color-stop(100%, lightgrey));
  background-image: -webkit-linear-gradient(#f3f3f3, lightgrey);
  background-image: linear-gradient(#f3f3f3, lightgrey);
  color: #A8A8A8;
  cursor: default; }
 
.pageplugin a:first-child {
 border: none;
 border-radius: 2px 0 0 2px; }
 
.pageplugin a:last-child {
 border: none;
 border-radius: 0 2px 2px 0; }
 
 .pageplugin .present {
 float: left;
 margin: 0;
 padding: 0;
 width: 120px;
 height: 20px;
 outline: none;
 border: none;
 vertical-align: middle;
 text-align: center; }

jquery分頁插件cypager

cypager是網友分享到JquerySchool網站上的一款作品,非常實用,經過測試,插件兼容 IE8+,Chrome,Firefox 瀏覽器,核心文件僅 5KB。。。

調用方式

由于是 jquery插件,所以在引人 cypager.min.js 之前,要引人 jquery.min.js 本人使用的是 1.7.2 版本的,低版本的沒試過。
引入css : <link rel="stylesheet" />
引人js : <script type="text/javascript" src="http://www.gimoo.net/t/1904/js/cypager.min.js"/>

$(function(){
  $("#pagerArea").cypager({pg_size:10,pg_nav_count:8,pg_total_count:194,pg_call_fun:function(count){
    alert("跳轉至頁面:"+count+"");
  }});
});

參數說明
pgerId //插件的ID 默認 : cy_pager
pg_size //每頁顯示記錄數 默認:10條
pg_cur_count //當前頁數(如果需要默認顯示指定頁面,則設置)
pg_total_count //總記錄數
pg_nav_count //顯示多少個導航數 默認:7個
pg_prev_name //上一頁按鈕名稱(默認:PREV)
pg_next_name //下一頁按鈕名稱 (默認:NEXT)
pg_call_fun(page_count) //回調函數,點擊按鈕執行

高效JQUERY分頁插件源代碼JQUERY.PAGER.JS

本文將給大家分享一個非常不錯的分頁插件、jQuery.pager.js、該插件的優點是可以內容索引、使用了jQuery、也同時調用了jquery.pager.js文件、分頁都是基于Ajax的、當然、如果你不打算使用Ajax來實現分頁的話、那么你最好不要使用本插件、若使用的話反而很麻煩、本插件主要是為使用Ajax技術交互的網站所準備、可以很方便的嵌入到網站系統中、實現Ajax分頁功能、如果大家覺得這個效果不是很好看的話、可以自己重寫分頁按鈕的樣式哈

HTML代碼很簡單、只要準備一個用于分頁代碼的DIV就可以了

<div class="tcdPageCode"></div>

通過jQuery的方式調用即可

$(".tcdPageCode").createPage({
 pageCount:6,
 current:1,
 backFn:function(p){
 console.log(p);
 }
});


主站蜘蛛池模板: 生理卫生课程| 影片《边境》| 《密爱》| jayden jaymes| 《美之罪》在线观看| 赵又廷电影| 爱情最美丽 电视剧| 金发女郎| 手纹线| 大尺度激情吻戏| 玫瑰的故事万茜演的什么角色| 学生基本情况分析| jar of love完整版| 夜夜做新郎| 荡寇电视剧演员表| 混凝土结构施工质量验收规范gb50204-2015 | 员工的秘密| 黄视频免费观看网站| 人总要有点爱好,生活才能继续 | 张学友电影全部作品| 18岁在线观看| 都市频道节目表今天| 韩国电影销售| 七年级下册英语书电子版单词表| 皇家师姐| 琅琊榜3第三部免费播放| 马樱花| 火火| 极寒之城在线观看高清完整| 美女污视频网站| 欲望中的女人电影| 卡通频道| 韩国电影解禁男女| 所求皆所愿| 火花 电影| 免费成人视屏| 少儿不宜视频| 怀孕被打肚子踩肚子踹肚子压肚子视频| jif| 纳尼亚传奇4在线观看免费完整版 虞书欣新剧永夜星河免费观看 | 祈今朝 电视剧|

!!!站長長期在線接!!!

網站、小程序:定制開發/二次開發/仿制開發等

各種疑難雜癥解決/定制接口/定制采集等

站長微信:lxwl520520

站長QQ:1737366103