ITPub博客

首页 > IT职业 > IT图书 > jQuery分页

jQuery分页

IT图书 作者:cookye 时间:2021-09-09 09:51:37 0 删除 编辑
html>
    
    分页
    
    
                                                                                                            
产品类别名称描述
         
'); //新建div,放入a标签,显示底部分页码         var pre = $('')        var next = $('')        var next1 = $('')        for (var pageIndex = 0; pageIndex ' +                    '' + (pageIndex + 1) + '' +                    '')                 .bind("click", { "newPage": pageIndex }, function(event) {                     currentPage = event.data["newPage"];                     $table.trigger("paging");                    //触发分页函数                 }).appendTo($pager);            if (sumPages === 1) { // 如果只有一页数据,左右都是灰色                 $pager.append(next1).prepend(pre);             } else { // 如果有多页数据,左边是灰色,右边是黑色                 $pager.append(next).prepend(pre);             }         }         $pager.insertAfter($table);         $table.trigger("paging");        // 给点击的页数添加蓝色         $('.pageStyle').each(function() {             $('.pageStyle').eq(0).addClass("active")             $(this).click(function() {                 $(this).addClass("active").siblings().removeClass("active");             })         })        // 向前点击         $(".pre").click(function(event) {            if (currentPage > 0) {                 currentPage -= 1                 $table.trigger("paging");                 $('.pageStyle').eq(currentPage).addClass("active").siblings().removeClass("active")                 $(".next").removeClass("next_gray").addClass("next_black")                 $(".pre").removeClass("pre_gray").addClass("pre_black")                if (currentPage === 0) {                     $(".pre").removeClass("pre_black").addClass("pre_gray")                     $(".next").removeClass("next_gray").addClass("next_black")                 }             }         })        // 点击后一条         $(".next").click(function(event) {            if (currentPage = 1 && currentPage 

效果:


图片描述

效果



作者:椰果粒
链接:https://www.jianshu.com/p/6ab50916eaa6


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1369/viewspace-2813546/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    91
  • 访问量
    502