我的表有n行,如果我对表使用分页,则分页器非常大。有没有办法限制分页?例如,分页应该包含1、2、3,单击下一步时,1、2、3应该被4、5、6等替换。这样分页就不会跳出屏幕。我尝试了很多变化与我的代码,它不工作。有谁能帮我一下吗?
我发现了一个jQuery插件,应该非常有帮助。这里有一个链接。
一旦你用这段代码设置好了:
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="//raw.github.com/botmonster/jquery-bootpag/master/lib/jquery.bootpag.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
</head>
<body>
<div id="content">Dynamic Content goes here</div>
<div id="page-selection">Pagination goes here</div>
<script>
// init bootpag
$('#page-selection').bootpag({
total: 10
}).on("page", function(event, /* page number here */ num){
$("#content").html("Insert content"); // some ajax content loading...
});
</script>
</body>
</html>
你可以这样写:
$('.demo3').bootpag({
total: 500,
page: 3,
maxVisible: 3,
href: "#pro-page-{{number}}",
leaps: false,
next: 'next',
prev: null
}).on('page', function(event, num){
$(".content3").html("Page " + num); // or some ajax content loading...
});
请告诉我是否有帮助。