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);
    }
  • 相关阅读:
    .NET Core中如何对Url进行编码和解码
    How to signout from an Azure Application?(转载)
    2016阿里安全峰会重点资料下载
    只有程序员才看懂的内涵图
    2016乌云白帽资料下载
    Python黑帽编程2.1 Python编程哲学
    Python黑帽编程2.2 数值类型
    Python黑帽编程 2.0 第二章概述
    PYTHON黑帽编程1.5 使用WIRESHARK练习网络协议分析
    乌云挂了,知识库的文章却在流传
  • 原文地址:https://www.cnblogs.com/zouke1220/p/8176134.html
Copyright © 2011-2022 走看看