首页  >  文章  >  web前端  >  jQuery 无刷新分页实例代码_jquery

jQuery 无刷新分页实例代码_jquery

WBOY
WBOY原创
2016-05-16 17:15:44862浏览

复制代码 代码如下:


    

       
       
       

                    var feedback = "";

                    $.each(data.list, function(index, d) {
                        var str ="";
                        str+= "

";
                        feedback += str;
                        });
                    $("#feedback").empty().append(feedback); //装载对应分页的内容

                    //alert(datac.list.length);
                    //var num_entries = $(".result").length;
                    var num_entries = data.list.length;
                    // 创建分页
                    $("#page").pagination(num_entries, {
                        num_edge_entries: 1, //边缘页数
                        num_display_entries: 5, //主体页数
                        callback: pageselectCallback,
                        items_per_page: 3, //每页显示1项
                        prev_text: "前一页",
                        next_text: "后一页"
                    });

                    pageselectCallback(0);
                    }

function pageselectCallback(page_index, jq){

    var resultList = $(".result");
    //var feedback = "";
    //alert(resultList.length);
    $(".result").each( function(index, data) {
            //alert(index);
            $(this).css('display','none');
            if(Math.floor(index/3)  == page_index){
            $(this).css('display','block');
            }
            });

    return false;
}
//ajax加载
$.getJSON("testPage",null, function(data){initPagination(data)});
});



声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn