今天在实现表格翻页功能时,出现一个问题
翻页代码如下:
function goPage(pageNo, pageSize) {
setTimeout(function() {
var table = document.getElementById(“users”);
var totalRecord = table.rows.length - 1;
var totalPage = 0;
var _pageSize = pageSize;
if(totalRecord / _pageSize > parseInt(totalRecord / _pageSize)) totalPage = parseInt(totalRecord / _pageSize) + 1;
else totalPage = parseInt(totalRecord / _pageSize);
var pageCurrent = pageNo;
var startRow = (pageCurrent - 1) * _pageSize + 1;
var endRow = pageCurrent * _pageSize;
endRow = (endRow > totalRecord) ? totalRecord : endRow;
for(var i = 1; i < (totalRecord + 1); i++) {
var row = table.rows[i];
console.log(row);
*** if(i >= startRow && i <= endRow) row.style.display = “block”;
*** else row.style.display = “none”;
}
var tempString = “共” + totalRecord + “条记录 共” + totalPage + “页 当前第” + pageCurrent + “页”;
if(pageCurrent > 1) {
tempString += “<a href=”#" onClick=“goPage(” + (1) + “,” + pageSize + “)”>首页";
tempString += “<a href=”#" onClick=“goPage(” + (pageCurrent - 1) + “,” + pageSize + “)”><上一页"
} else {
tempString += " 首页 “;
tempString += " <上一页 “;
}
if(pageCurrent < totalPage) {
tempString += “<a href=”#” onClick=“goPage(” + (pageCurrent + 1) + “,” + pageSize + “)”>下一页>”;
tempString += “<a href=”#" onClick=“goPage(” + totalPage + “,” + pageSize + “)”>尾页";
} else {
tempString += " 下一页> ";
tempString += " 尾页 ";
}
document.getElementById(“barcon”).innerHTML = tempString;
}, 100);
}
上面带星号的地方,如果注释掉就能正常显示但翻页功能无法实现
不注释掉就跟第一张图那个情况一样。。。
这是什么情况,请大神帮忙!!