中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

急急忙忙寫了個JS分頁。先存著了,有時候再改

發布時間:2020-06-28 13:12:30 來源:網絡 閱讀:454 作者:s363905520 欄目:編程語言
function Page(index, size, count) {
                var len = 10,
                        show = len - 3;


                var prev = $("<li />").addClass("prev").html('<a href="#">上一頁</a>');
                var next = $("<li />").addClass("next").html('<a href="#">下一頁</a>');
                var li;
                if (index <= 0) prev.addClass("disabled");
                if (index >= count / size || index + 1 >= count / size) next.addClass("disabled");
                var _p = $(".dataTables_paginate > ul");


                _p.html("");

                //上一頁
                prev.click(function () {
                        if (index > 0) load(index);
                });
                _p.append(prev);
                if (index * size >= count) {
                        li = $("<li />").html('<a href="#">1</a>').addClass("active");
                        _p.append(li);
                }
                var _page = (count % size) == 0 ? count / size : parseInt(count / size) + 1;
                if (index * size < count) {

                        if (_page <= len) {
                                for (var i = 1; i < _page + 1; i++) {
                                        li = $("<li />").html('<a href="#">' + i + '</a>');
                                        if (i === index + 1) li.addClass("active");
                                        _p.append(li);
                                }
                        }

                        if (_page > len) {

                                if (index < show) {
                                        for (var i = 1; i < 9; i++) {
                                                li = $("<li />").html('<a href="#">' + i + '</a>');
                                                if (i === index + 1) li.addClass("active");

                                                _p.append(li);
                                        }
                                        _p.append(li);
                                        $("<li />").html('<a href="#">...</a>').appendTo(_p);

                                        li = $("<li />").html('<a href="#">' + _page + '</a>');

                                        _p.append(li);

                                }
                                if (index >= show && index <= _page - show) {

                                        /* 第一頁*/
                                        li = $("<li />").html('<a href="#">1</a>');

                                        _p.append(li);

                                        $("<li />").html('<a href="#">...</a>').appendTo(_p);


                                        /*中間頁*/

                                        for (var i = index - 2; i < index + 6; i++) {
                                                li = $("<li />").html('<a href="#">' + i + '</a>');
                                                if (i === index + 1) li.addClass("active");
                                                _p.append(li);
                                        }


                                        /* 最后頁*/
                                        $("<li />").html('<a href="#">...</a>').appendTo(_p);

                                        li = $("<li />").html('<a href="#">' + _page + '</a>');

                                        _p.append(li);

                                }

                                if (index > _page - show) {
                                        /* 第一頁 */
                                        li = $("<li />").html('<a href="#">1</a>');

                                        _p.append(li);

                                        $("<li />").html('<a href="#">...</a>').appendTo(_p);


                                        /* 中間頁 */

                                        for (var i = _page - 8; i < _page + 1; i++) {
                                                li = $("<li />").html('<a href="#">' + i + '</a>');
                                                if (i === index + 1) li.addClass("active");

                                                _p.append(li);
                                        }

                                }

                        }
                        next.click(function () {
                                if (index < _page - 1) load(index + 2);
                        });
                        _p.append(next);

                        $("li:not(:first):not(:last) a").click(function () {
                                var _pa = $(this).text();
                                if (_pa != "...") {

                                        load(_pa);
                                }

                        });
                }
        }
CSS:
 

.pagination
{
        height
: 36px;
        margin
: 18px 0;
}

        .pagination ul
{
                display
: inline-block;
                *display
: inline;
                *zoom
: 1;
                margin-left
: 0;
                margin-bottom
: 0;
                -webkit-border-radius
: 3px;
                -moz-border-radius
: 3px;
                border-radius
: 3px;
                -webkit-box-shadow
: 0 1px 2px rgba(0, 0, 0, 0.05);
                -moz-box-shadow
: 0 1px 2px rgba(0, 0, 0, 0.05);
                box-shadow
: 0 1px 2px rgba(0, 0, 0, 0.05);
        }

                .pagination ul > li
{
                        display
: inline;
                }

                        .pagination ul > li > a, .pagination ul > li > span
{
                                float
: left;
                                padding
: 0 14px;
                                line-height
: 34px;
                                text-decoration
: none;
                                background-color
: #ffffff;
                                border
: 1px solid #dddddd;
                                border-left-width
: 0;
                        }

                                .pagination ul > li > a:hover, .pagination ul > .active > a, .pagination ul > .active > span
{
                                        background-color
: #f5f5f5;
                                }

                .pagination ul > .active > a, .pagination ul > .active > span
{
                        color
: #999999;
                        cursor
: default;
                }

                .pagination ul > .disabled > span, .pagination ul > .disabled > a, .pagination ul > .disabled > a:hover
{
                        color
: #999999;
                        background-color
: transparent;
                        cursor
: default;
                }

                .pagination ul > li:first-child > a, .pagination ul > li:first-child > span
{
                        border-left-width
: 1px;
                        -webkit-border-radius
: 3px 0 0 3px;
                        -moz-border-radius
: 3px 0 0 3px;
                        border-radius
: 3px 0 0 3px;
                }

                .pagination ul > li:last-child > a, .pagination ul > li:last-child > span
{
                        -webkit-border-radius
: 0 3px 3px 0;
                        -moz-border-radius
: 0 3px 3px 0;
                        border-radius
: 0 3px 3px 0;
                }

.pagination-centered
{
        text-align
: center;
}

.pagination-right
{
        text-align
: right;
}
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

宁津县| 麻阳| 台安县| 临漳县| 伊通| 石渠县| 阳新县| 高阳县| 彭水| 高唐县| 花莲县| 永兴县| 宣武区| 广安市| 长丰县| 兴文县| 乐东| 涿州市| 芮城县| 平度市| 隆回县| 灵武市| 三河市| 肇东市| 东明县| 虎林市| 深州市| 澜沧| 南投县| 丰原市| 射洪县| 上蔡县| 扎兰屯市| 北宁市| 塔城市| 六盘水市| 叶城县| 夏津县| 黄骅市| 天等县| 友谊县|