function pageAjax (pageNum) { var arr = selecPage(); var html = ''; var n = pageNum - 1; arr.forEach(function(v,i){ if(n == i){ html += v; } }) $("#box").html(html); } pageAjax(1) var Page = (function(){ var Page = function(obj){ return fn.init(obj); } var fn = Page.prototype = { init:function(obj){ this.pageCount = obj.pageCount; this.pageSize = obj.pageSize || 7; this.pageNow = obj.pageNow || 1; this.containerId = obj.id; this.container = document.getElementById(this.containerId); fn.drawPage(); return this; }, drawPage:function(){ this.container.innerHTML = ""; var front = document.createElement("a"); var next = document.createElement("a"); this.acontainer = document.createElement("sapn"); front.innerHTML = "<"; next.innerHTML = ">"; front.className = "front"; next.className = "next"; this.container.appendChild(front); $(front).on("click",function(){ fn.frontOrNext(this,true); fn.inputBox.value = fn.pageNow; }) $(next).on("click",function(){ fn.frontOrNext(this,false); fn.inputBox.value = fn.pageNow; }) this.front = front; this.next = next; if(this.pageCount<= this.pageSize){ for( var i=0;i=fn.pageSize-1){
fn.reset();
}
etc2.className = "etc";
fn.inputBox.value = this.innerHTML;
})
this.acontainer.appendChild(a);
if(i+1 == this.pageNow){
a.className = "select";
}
}
fn.check();
this.acontainer.appendChild(etc2);
fn.pageN()
}else{
fn.reset();
}
}
网友评论