js实现数字分页
///js数字分页 返回数组
function page(pageCount, sideNum, pageNum) {
//其实页
var startNum = 0;
//结束页
var endNum = 0;
var val = Math.ceil(pageNum / sideNum);
var midpage = Math.ceil(sideNum / 2);
if (sideNum > pageCount) {
endNum = pageCount;
} else {
if (pageNum <= midpage) {
endNum = sideNum;
}
else {
endNum = pageNum + midpage - 1;
if (endNum > pageCount) {
endNum = pageCount;
}
}
}
if (endNum <= sideNum) {
startNum = 1;
}
else {
startNum = endNum - sideNum + 1;
}
//创建数组实现数字分页
var a = new Array();
for (var i = startNum; i <= endNum; i++) {
a[i] = i;
}
return a;
}