求高手帮忙用js对列表进行分页
<divclass="PicList"><dl><dd><ahref="#">携笔从戎无上光荣</dd><dd><ahref="#">女兵风采</a></dd><dd><...
<div class="PicList">
<dl>
<dd>
<a href="#">携笔从戎无上光荣
</dd>
<dd>
<a href="#">女兵风采</a></dd>
<dd>
<a href="#">每一个神枪手在是在一枪一...</a>
</dd>
<dd>
<a href="#">今日的誓言注定了明日的成...</a>
</dd>
<dd>
<a href="#">今天的付出决定明日的收获</a>
</dd>
<dd>
<a href="#">汗水与泪水的交织</a>
</dd>
<dd>
<a href="#">女兵风采</a></dd>
<dd>
<a href="#">每一个神枪手在是在一枪一...</a>
</dd>
<dd>
<a href="#">今日的誓言注定了明日的成...</a>
</dd>
<dd>
<a href="#">今天的付出决定明日的收获</a>
</dd>
<dd>
<a href="#">汗水与泪水的交织</a>
</dd>
</dl>
<div class="pagess" style="margin-top: 15px; text-align: center; *margin-top: 15px;
_margin-top: 15px">
<span id="spanFirst">首页</span> <span id="spanPre">上一页</span> <span id="spanNext">下一页</span>
<span id="spanLast">尾页</span> 第<span id="spanPageNum"></span>页/共<span id="spanTotalPage"></span>页
</div>
</div>
请高手帮忙:对每三个<dd></dd>分一页,先谢谢了 展开
<dl>
<dd>
<a href="#">携笔从戎无上光荣
</dd>
<dd>
<a href="#">女兵风采</a></dd>
<dd>
<a href="#">每一个神枪手在是在一枪一...</a>
</dd>
<dd>
<a href="#">今日的誓言注定了明日的成...</a>
</dd>
<dd>
<a href="#">今天的付出决定明日的收获</a>
</dd>
<dd>
<a href="#">汗水与泪水的交织</a>
</dd>
<dd>
<a href="#">女兵风采</a></dd>
<dd>
<a href="#">每一个神枪手在是在一枪一...</a>
</dd>
<dd>
<a href="#">今日的誓言注定了明日的成...</a>
</dd>
<dd>
<a href="#">今天的付出决定明日的收获</a>
</dd>
<dd>
<a href="#">汗水与泪水的交织</a>
</dd>
</dl>
<div class="pagess" style="margin-top: 15px; text-align: center; *margin-top: 15px;
_margin-top: 15px">
<span id="spanFirst">首页</span> <span id="spanPre">上一页</span> <span id="spanNext">下一页</span>
<span id="spanLast">尾页</span> 第<span id="spanPageNum"></span>页/共<span id="spanTotalPage"></span>页
</div>
</div>
请高手帮忙:对每三个<dd></dd>分一页,先谢谢了 展开
展开全部
我已经把分页做好了,剩下的你应该可以解决!
var ObjPage = {};
///总记录数
ObjPage.RecordCount = 0;
///总共页数
ObjPage.PageCount = 0;
///当前页数, 1为第一页
ObjPage.PageIndex = 1;
///每页记录数
ObjPage.PageSize = 3;
///生成分页按钮
ObjPage.Fun = function () {
var sb = '';
if (ObjPage.PageIndex <= 1) {
sb += '<span id="spanFirst" val="0">首页</span> <span id="spanPre" val="0">上一页</span>';
} else {
sb += '<span id="spanFirst" val="1">首页</span> <span id="spanPre" val="' + (ObjPage.PageIndex - 1) + '">上一页</span>';
}
if (ObjPage.PageIndex >= ObjPage.PageCount) {
sb += '<span id="spanNext" val="0">下一页</span> <span id="spanLast" val="0">尾页</span>';
} else {
sb += '<span id="spanNext" val="' + (ObjPage.PageIndex + 1) + '">下一页</span> <span id="spanLast" val="' + (ObjPage.PageCount) + '">尾页</span>';
}
sb += '第<span id="spanPageNum">' + ObjPage.PageIndex + '</span>页/共<span id="spanTotalPage">' + ObjPage.PageCount + '</span>页';
$(".pagess").html(sb);
};
///初始化数据
ObjPage.Load = function () {
var PicList = $(".PicList");
var dd_length = PicList.find("dd").length;
ObjPage.RecordCount = dd_length;
var PageCount = dd_length % ObjPage.PageSize>0?1:0;
ObjPage.PageCount = parseInt(dd_length / ObjPage.PageSize) + PageCount;
ObjPage.Fun();
};
$(function () {
ObjPage.Load();
$("#spanPre,#spanNext,#spanLast,#spanFirst").live("click", function () {
var v_val = parseInt($(this).attr("val"));
if (v_val == 0) {
var v_id = $(this).attr("id"); alert(v_id);
switch (v_id) {
case "spanLast":
alert("已经是尾页");
break;
case "spanFirst":
alert("已经是首页");
break;
}
return;
}
ObjPage.PageIndex = v_val;
ObjPage.Fun();
});
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询