$(".prev").on("click", item => {
let max_page = $("#maxpage").val()
let page = getUrlParam('page');
if (page > 1) {
page--;
reLoad('page',page);
} else {
alert("已经是第一页了")
}
});
$(".next").on("click", item => {
let max_page = $("#maxpage").val()
let page = getUrlParam('page');
if (page < max_page) {
page++;
reLoad('page',page);
} else {
alert("已经是最后一页了")
}
});
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
function reLoad(p, v) {
var url = window.location.href;
var par = p + "=" + v;
if (getUrlParam(p) == null)
location.href = url + (url.indexOf("?") > 0 ? "&" : "?") + par;
else
location.href = url.replace(eval('/(' + p + '=)([^&]*)/gi'), par);
}
|