当前位置: 首页 > news >正文

家庭路由器建个人网站/怎么优化网站

家庭路由器建个人网站,怎么优化网站,cms 政府网站 模板 div css,做不锈钢百度网站哪个比较好自己写的一个简单的分页组件,主要功能还有实现都在JS中,html页面中只用增加一个放置生成分页的DIV,并给定容器的id.html结构如下:class"pagination" 给定了分页的样式,id"pageDIV"用于放置JS生成的分页CSS结构如下:.pagination{margin-top: 10px;margin-bo…

自己写的一个简单的分页组件,主要功能还有实现都在JS中,html页面中只用增加一个放置生成分页的DIV,并给定容器的id.

html结构如下:

class="pagination" 给定了分页的样式,

id="pageDIV"用于放置JS生成的分页

CSS结构如下:

.pagination{

margin-top: 10px;

margin-bottom: 10px;

display: inline-block;

padding-left: 0;

margin: 20px 0;

border-radius: 4px;

}

.pagination>li {

display: inline;

}

.pagination>li:first-child>a{

margin-left: 0;

border-top-left-radius: 4px;

border-bottom-left-radius: 4px;

}

.pagination>li>a{

position: relative;

float: left;

padding: 6px 12px;

margin-left: -1px;

line-height: 1.42857143;

color: #337ab7;

text-decoration: none;

background-color: #fff;

border: 1px solid #ddd;

cursor: pointer;

}

.pagination>li>a.navcur{

background: #cccccc;

color: #ffffff;

}

下面是JS结构,注意要引用JQuery

/**

* @pageContentID 渲染分页的DIV元素

* @curPage 当前开始页

* @totalCount 总数量

* @pageRows 每页显示数量

* @callback 显示数据的回调函数

*/

function PageList(pageContentID,option){

this.pageContentID=document.getElementById(pageContentID);

this.curPage=option.curPage;

this.totalCount=option.totalCount;

this.pageRows=option.pageRows;

this.callback=option.callback;

this.pageSize=Math.ceil(this.totalCount/this.pageRows);

}

PageList.prototype={

init:function(){

this.renderbtn();

},

firstpage:function(){

var _self=this;

_self._firstpage=document.createElement("li");

_self._firstpageA=document.createElement("a");

_self._firstpageA.innerHTML="首页";

_self._firstpage.appendChild(_self._firstpageA);

this.pageContentID.appendChild(_self._firstpage);

_self._firstpage.οnclick=function(){

_self.gotopage(1);

}

},

lastpage: function () {

var _self=this;

_self._lastpage=document.createElement("li");

_self._lastpageA=document.createElement("a");

_self._lastpageA.innerHTML="尾页";

_self._lastpage.appendChild(_self._lastpageA);

this.pageContentID.appendChild(_self._lastpage);

_self._lastpage.οnclick= function () {

_self.gotopage(_self.pageSize);

}

},

prewpage: function () {

var _self=this;

_self._prew=document.createElement("li");

_self._prewA=document.createElement("a");

_self._prewA.innerHTML="<

_self._prew.appendChild(_self._prewA);

this.pageContentID.appendChild(_self._prew);

_self._prew.οnclick= function () {

if(_self.curPage>1){

_self.curPage--;

}

_self.callback.call(this,this.curPage);

_self.init();

console.log(_self.curPage);

}

},

nextpage: function () {

var _self=this;

_self._next=document.createElement("li");

_self._nextA=document.createElement("a");

_self._nextA.innerHTML=">>";

_self._next.appendChild(_self._nextA);

this.pageContentID.appendChild(_self._next);

_self._next.οnclick= function () {

if(_self.curPage<_self.pagesize>

_self.curPage++;

}

_self.callback.call(this,this.curPage);

_self.init();

console.log(_self.curPage);

}

},

pagenum: function () {

var _self=this;

if(this.pageSize<=10){

for(var i= 1,len=this.pageSize;i<=len;i++){

_self._num=document.createElement("li");

_self._numA=document.createElement("a");

_self._numA.innerHTML=i;

_self._num.appendChild(_self._numA);

this.pageContentID.appendChild(_self._num);

_self._num.οnclick= function () {

var curpage = $(this).text();

_self.gotopage(curpage);

}

}

}

else{

if(_self.curPage<=10){

for(var i= 1;i<=10;i++){

_self._num=document.createElement("li");

_self._numA=document.createElement("a");

_self._numA.innerHTML=i;

_self._num.appendChild(_self._numA);

this.pageContentID.appendChild(_self._num);

_self._num.οnclick= function () {

var curpage = $(this).text();

_self.gotopage(curpage);

}

}

}

else if(_self.curPage>10&&_self.curPage<=this.pageSize){

if(this.pageSize

for(var i=Math.floor(_self.curPage/10)*10+1;i<=this.pageSize;i++){

if(_self.curPage>this.pageSize)

return;

_self._num=document.createElement("li");

_self._numA=document.createElement("a");

_self._numA.innerHTML=i;

_self._num.appendChild(_self._numA);

this.pageContentID.appendChild(_self._num);

_self._num.οnclick= function () {

var curpage = $(this).text();

_self.gotopage(curpage);

}

}

}else{

if(Math.ceil(_self.curPage/10)*10==_self.curPage){

for(var i=_self.curPage-9;i<=_self.curPage;i++){

_self._num=document.createElement("li");

_self._numA=document.createElement("a");

_self._numA.innerHTML=i;

_self._num.appendChild(_self._numA);

this.pageContentID.appendChild(_self._num);

_self._num.οnclick= function () {

var curpage = $(this).text();

_self.gotopage(curpage);

}

}

}else{

for(var i=Math.floor(_self.curPage/10)*10+1;i<=Math.ceil(_self.curPage/10)*10;i++){

_self._num=document.createElement("li");

_self._numA=document.createElement("a");

_self._numA.innerHTML=i;

_self._num.appendChild(_self._numA);

this.pageContentID.appendChild(_self._num);

_self._num.οnclick= function () {

var curpage = $(this).text();

_self.gotopage(curpage);

}

}

}

}

}

}

$(".pagination li").each(function(){

if($(this)[0].innerText==_self.curPage){

$(".pagination li").children("a").removeClass("navcur");

$(this).children("a").addClass("navcur");

}

});

},

gotopage: function (curpage) {

this.curPage=curpage;

this.callback.call(this,this.curPage);

this.init();

console.log(this.curPage);

},

renderbtn: function () {

$(".pagination").html("");

this.firstpage();

this.prewpage();

this.pagenum();

this.nextpage();

this.lastpage();

}

};

$(function(){

var pager = new PageList("pageDIV",{

curPage:1,

totalCount:26,

pageRows:1,

callback:callbackFuc

});

pager.init();

});

function callbackFuc(curpage){

}

说明:

此分页是以10页为标准,低于10页的时候全部显示,大于10页的时候,进行翻页显示余下页数.

调用方法:

$(function(){

var pager = new PageList("pageDIV",{

curPage:1,

totalCount:26,

pageRows:1,

callback:callbackFuc

});

pager.init();

});

以上就是本分页组件的核心代码了,希望小伙伴们能够喜欢。

http://www.lbrq.cn/news/1314019.html

相关文章:

  • wordpress怎么改后台/京东关键词优化技巧
  • 做动画 的 网站有哪些内容/百度怎么联系客服
  • 网站备案手机号/深圳电子网络推广查询
  • 新网站怎么做排名/seo查询系统
  • 一个做网站编程的条件/爱站工具下载
  • 郴州网站设计公司/win10优化大师好用吗
  • 网络公司网站模版/奉化网站关键词优化费用
  • 大型建站网站/百度免费推广平台
  • 全球云邮登陆网站/网页设计与制作作业成品
  • 线上网站制作/培训平台有哪些
  • 贵州住房和城乡建设委员会网站/山东建站
  • 哪些网站是做采购的/竞价关键词排名软件
  • 根据网站日志做seo/做推广网络
  • 电脑有固定IP 做网站/关键词推广营销
  • 江苏专业网站建设/建站推广
  • 本地最好的网站开发建设公司/nba排名最新赛程
  • 网络管理专业/魔方优化大师官网
  • 免费网站安全/优化大师官方网站
  • 宁波建网站报价/企业网站优化方案
  • 网站建设军成/百度云网盘资源搜索引擎入口
  • 用flask做网站/合肥seo优化公司
  • 山东手机网站建设公司/莱阳seo排名
  • 建设厅安全员证书查询网站/开淘宝店铺怎么运营推广
  • 在统计局网站上如何做图表/企业培训课程视频
  • 网络营销网站建设知识/深圳seo公司
  • 临淄区建设局网站/竞价推广代运营服务
  • 网站可以个人做吗/如何广告推广
  • 企业网站 建设 外包/电子商务是干什么的
  • 网站产品展示怎么做/互联网运营推广是做什么的
  • 科技信息网站建设的背景/桂林seo顾问
  • sglang笔记1: 后端详细阅读版
  • Java线程池深度解析与Spring Boot实战指南
  • 【网络工程师软考版】计算机组成原理
  • 【Flask】基础入门
  • GD32 CAN1和TIMER0同时开启问题
  • 【PycharmPyqt designer桌面程序设计】