亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        基于jquery編寫(xiě)分頁(yè)插件

        字號(hào):


            擴(kuò)展JQuery很容易,作為一個(gè)練習(xí),編寫(xiě)一個(gè)簡(jiǎn)單的分頁(yè)插件,代碼量不大,直接看代碼好了:
            $.fn.mypagination = function(totalProperty,opts){ 
              opts = $.extend({ 
                perPage:10, 
                callback:function(){ 
                } 
              },opts||{}); 
              return this.each(function(){ 
                function numPages(){ 
                  return Math.ceil(totalProperty/opts.perPage); 
                } 
                function selectPage(page){ 
                  return function(){ 
                    currPage = page; 
                    if (page<0) currPage = 0; 
                    if (page>=numPages()) currPage = numPages()-1; 
                    render(); 
                    $('img.page-wait',panel).attr('src','images/wait.gif'); 
                    opts.callback(currPage+1); 
                    $('img.page-wait',panel).attr('src','images/nowait.gif'); 
                  } 
                } 
                function render(){ 
                  var html = '<table><tbody><tr>' 
                    +'<td><a href="#"><img></a></td>'
                    +'<td><a href="#"><img></a></td>'
                    +'<td><span>第<input type="text">頁(yè)/共'+numPages()+'頁(yè)</span></td>'
                    +'<td><a href="#"><img></a></td>'
                    +'<td><a href="#"><img></a></td>'
                    +'<td><img src="images/nowait.gif"></td>'
                    +'<td><span>檢索到'+totalProperty+'記錄</span></td>'
                    +'</tr></tbody></table>'; 
                  var imgFirst = 'images/page-first-disabled.gif'; 
                  var imgPrev = 'images/page-prev-disabled.gif'; 
                  var imgNext = 'images/page-next-disabled.gif'; 
                  var imgLast = 'images/page-last-disabled.gif'; 
                  if (currPage > 0){ 
                    imgFirst = 'images/page-first.gif'; 
                    imgPrev = 'images/page-prev.gif'; 
                  } 
                  if (currPage < numPages()-1){ 
                    imgNext = 'images/page-next.gif'; 
                    imgLast = 'images/page-last.gif'; 
                  } 
                  panel.empty(); 
                  panel.append(html); 
                  $('img.page-first',panel) 
                    .bind('click',selectPage(0)) 
                    .attr('src',imgFirst);  
                  $('img.page-prev',panel) 
                    .bind('click',selectPage(currPage-1)) 
                    .attr('src',imgPrev);   
                  $('img.page-next',panel) 
                    .bind('click',selectPage(currPage+1)) 
                    .attr('src',imgNext);   
                  $('img.page-last',panel) 
                    .bind('click',selectPage(numPages()-1)) 
                    .attr('src',imgLast); 
                  $('input.page-num',panel) 
                    .val(currPage+1) 
                    .change(function(){ 
                      selectPage($(this).val()-1)(); 
                    }); 
                } 
                var currPage = 0; 
                var panel = $(this); 
                render(); 
              }); 
            } 
            下面測(cè)試一下:
            <head> 
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
              <link rel="stylesheet" href="mypagination.css"/> 
              <script type="text/javascript" src="jquery-1.2.6.js"></script> 
              <script type="text/javascript" src="jquery.mypagination.js"></script> 
              <script> 
                $(document).ready(function(){ 
                  $('#mypage').mypagination(10112,{ 
                    callback:function(page){ 
                      alert(page); 
                    } 
                  }); 
                }); 
              </script> 
            </head> 
            <div id="mypage"></div> 
            運(yùn)行效果圖如下:
            名單
            以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助。