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);
    }
  • 相关阅读:
    IOS compare 字符串比较
    Cocoa Touch事件处理流程--响应者链
    真机测试及布署Code Sign error问题总结
    CG_INLINE,inline 内联函数
    objective-c static变量的使用总结
    iOS用户信息单例的创建
    UITextField-修改占位文字和光标的颜色,大小
    iOS应用程序生命周期(前后台切换,应用的各种状态)详解
    深入理解RunLoop
    jQuery文件上传插件uploadify
  • 原文地址:https://www.cnblogs.com/zouke1220/p/8176134.html
Copyright © 2011-2022 走看看