function showMsg(){查询数据;}
window.onload=showMsg();
function goPage(pno,psize){
var itable = document.getElementById("adminTbody");
var num = itable.rows.length;//表格所有行数(所有记录数)
var totalPage = 0;//总页数
var pageSize = psize;//每页显示行数
//总共分几页
if(num/pageSize > parseInt(num/pageSize)){
totalPage=parseInt(num/pageSize)+1;
}else{
totalPage=parseInt(num/pageSize);
}
var currentPage = pno;//当前页数
var startRow = (currentPage - 1) * pageSize+1;
var endRow = currentPage * pageSize;
endRow = (endRow > num)? num : endRow;
//遍历显示数据实现分页
for(var i=1;i<(num+1);i++){
var irow = itable.rows[i-1];
if(i>=startRow && i<=endRow){
irow.style.display = "";
}else{
irow.style.display = "none";
}
}
var tempStr = "共"+num+"条记录 分"+totalPage+"页 当前第"+currentPage+"页";
document.getElementById("barcon1").innerHTML = tempStr;
$("#firstPage").on("click",function(){
goPage(1,pageSize);
})
$("#prePage").on("click",function(){
goPage(currentPage-1,pageSize);
})
$("#nextPage").on("click",function(){
goPage(currentPage+1,pageSize);
})
$("#lastPage").on("click",function(){
goPage(totalPage,pageSize);
})
}
<body onload="goPage(1,15);">
<input type="button" onclick="showMsg();" value="查询" />
点击查询只能查询出数据,分页没有用
点击上一页下一页分页有效,请问要怎么执行这个分页函数