zoukankan      html  css  js  c++  java
  • 分页--pagination.js

    var pagination = function (thispage, totalpage, ulele, firstlast) {
        ulele.html('');
        var prevCss, nextCss, firstCss, lastCss;
    
        firstCss = $('<li></li>', {
            "class": thispage == 1 ? 'prev disabled' : 'prev'
        }).append($(thispage == 1 ? '<span></span>' : '<a></a>', thispage == 1 ? {} : {"href": location.href.addParam('page', 1)}).html("首页"));
        lastCss = $('<li></li>', {
            "class": thispage == totalpage ? 'next disabled' : 'next'
        }).append($(thispage == totalpage ? '<span></span>' : '<a></a>', thispage == totalpage ? {} : {"href": location.href.addParam('page', totalpage)}).html("末页"));
        prevCss = $('<li></li>', {
            "class": thispage == 1 ? 'prev disabled' : 'prev'
        }).append($(thispage == 1 ? '<span></span>' : '<a></a>', thispage == 1 ? {} : {"href": location.href.addParam('page', totalpage - 1)}).html("&lt;上一页"));
        nextCss = $('<li></li>', {
            "class": thispage == totalpage ? 'next disabled' : 'next'
        }).append($(thispage == totalpage ? '<span></span>' : '<a></a>', thispage == totalpage ? {} : {"href": location.href.addParam('page', thispage + 1)}).html("下一页&gt;"));
    
        if(firstlast) firstCss.appendTo(ulele);
        prevCss.appendTo(ulele);
    
        if (thispage > 3) {
            $('<li></li>').append($('<a></a>', {"href": location.href.addParam('page', 1)}).html(1)).appendTo(ulele);
            $('<li><a><span>...</span></a></li>').appendTo(ulele);
        }
        for (var i = 1; i <= totalpage; i++) {
            if (i < thispage - 3 || i > thispage + 3) {
                continue;
            }
            var isActive = thispage == i ? 'active' : '';
            $('<li></li>', {
                "class": isActive
            }).append($('<a></a>', {"href": location.href.addParam('page', i)}).html(i)).appendTo(ulele);
        }
        if (totalpage - thispage > 3) {
            $('<li><a><span>...</span></a></li>').appendTo(ulele);
            $('<li></li>').append($('<a></a>', {"href": location.href.addParam('page', totalpage)}).html(totalpage)).appendTo(ulele);
        }
    
        nextCss.appendTo(ulele);
        if(firstlast) lastCss.appendTo(ulele);
    }
  • 相关阅读:
    【JavaWeb】Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JCaptcha 完整Web基础框架(前言)
    【CityHunter】游戏流程设计及技术要点
    lua table操作
    python线程池(转)
    windows通过企业内部授权服务器激活方法
    贝叶斯定理(转)
    python 日期计算
    python 过滤 b'及提取 cmd命令返回值
    python 连接MySQL数据库
    python 获取昨天的日期
  • 原文地址:https://www.cnblogs.com/zouke1220/p/8176134.html
Copyright © 2011-2022 走看看