js code to implement paging display
This article mainly shares with you the js code for paging display, hoping to help everyone.
1.The code in the HTML page is as follows
<p class="page"> </p>
2.JS code reference in HTML
<script src="js/jquery.min.js"></script> <script src="js/model.js"></script> <script src="js/page.js"></script>
<script type="text/javascript"> $(function() { // 初始化信息 paginate.use(1, 5); page(1); }); // 初始化变量 var url = model.bhost + "api/article/list.ht?type=1"; var template = $("#list_info").html(); /**翻页 */ function page(page){ paginate.goPage({url:url,template:template,contaner:".cbp_tmtimeline",page:page}); } </script>
3.JS extraction file
var paginate={ curPage:1, totalPage:0, pageSize:5, pageHtml:'<a href="javascript:page(${num})">${dpy}</a>', // 页码html模板 totalHtmlBefore:' <a title="Total record"><b id="total_num">',//总页数html totalHtmlAfter:'</b></a>', use:function(_curPage,_pageSize){ this.curPage = _curPage; this.pageSize = _pageSize; }, // 展示分页信息 showPage:function(maxPage, start, curPage){ // 清空分页信息 $(".page").html(""); // 加载分页信息 var list = paginate.createPageData(maxPage, start); model.loaderList(list, this.pageHtml, ".page"); // 显示总页数 $(".page").append(this.totalHtmlBefore + curPage+"/" +this.totalPage + this.totalHtmlAfter); // 显示当前页样式 $(".page a").css("color","#aee1ff"); $(".page a[href='javascript:page("+this.curPage+")']").css("color","#FF0000"); }, // 创建页码数据列表 createPageData:function(curPage, start){ var numList = []; numList.push(paginate.createObj(-1)); for(var i=start; i<=curPage; i++){ var numObj = paginate.createObj(i); if(numObj != null) numList.push(numObj); } numList.push(paginate.createObj(-2)); return numList; }, // 创建页码数据 createObj:function(i){ var numObj = {}; if(i == -2){ numObj.num = "-2"; numObj.dpy = ">"; }else if(i == -1){ numObj.num = "-1"; numObj.dpy = "<"; }else{ numObj.num = i+""; numObj.dpy = i+""; } return numObj; }, getCurPage:function(page){ if(page == "-2"){ paginate.curPage = paginate.curPage +1; }else if(page == "-1"){ paginate.curPage = paginate.curPage-1; }else{ paginate.curPage = page; } }, // 跳转 goPage:function(params){ // 当前页计算 paginate.getCurPage(params.page); if(paginate.curPage < 1){ paginate.curPage = 1; return; } // 查询信息 $.get(params.url+"&pageNum="+paginate.curPage+"&pageSize="+paginate.pageSize, function(result) { // 当前页大于总页数,数据不刷新 paginate.totalPage = result.totalPage; if(paginate.curPage > result.totalPage){ paginate.curPage = result.totalPage; return; } // 当前页小于6页 if(paginate.curPage < 6){ var maxPage = result.totalPage; if(maxPage > 5)maxPage=5; paginate.showPage(maxPage, 1, paginate.curPage); }else{ paginate.showPage(paginate.curPage, paginate.curPage-4, paginate.curPage); } // 列表信息显示 $(params.contaner).html(''); model.loaderList(result.data, params.template, params.contaner); $(".cbp_tmlabel").css("opacity", "1");// 显示列表信息 }); } };
4.Interface return type
The above is the detailed content of js code to implement paging display. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



What to do with blue screen code 0x0000001? The blue screen error is a warning mechanism when there is a problem with the computer system or hardware. Code 0x0000001 usually indicates a hardware or driver failure. When users suddenly encounter a blue screen error while using their computer, they may feel panicked and at a loss. Fortunately, most blue screen errors can be troubleshooted and dealt with with a few simple steps. This article will introduce readers to some methods to solve the blue screen error code 0x0000001. First, when encountering a blue screen error, we can try to restart

Termination Code 0xc000007b While using your computer, you sometimes encounter various problems and error codes. Among them, the termination code is the most disturbing, especially the termination code 0xc000007b. This code indicates that an application cannot start properly, causing inconvenience to the user. First, let’s understand the meaning of termination code 0xc000007b. This code is a Windows operating system error code that usually occurs when a 32-bit application tries to run on a 64-bit operating system. It means it should

If you need to program any device remotely, this article will help you. We will share the top GE universal remote codes for programming any device. What is a GE remote control? GEUniversalRemote is a remote control that can be used to control multiple devices such as smart TVs, LG, Vizio, Sony, Blu-ray, DVD, DVR, Roku, AppleTV, streaming media players and more. GEUniversal remote controls come in various models with different features and functions. GEUniversalRemote can control up to four devices. Top Universal Remote Codes to Program on Any Device GE remotes come with a set of codes that allow them to work with different devices. you may

What does the 0x000000d1 blue screen code mean? In recent years, with the popularization of computers and the rapid development of the Internet, the stability and security issues of the operating system have become increasingly prominent. A common problem is blue screen errors, code 0x000000d1 is one of them. A blue screen error, or "Blue Screen of Death," is a condition that occurs when a computer experiences a severe system failure. When the system cannot recover from the error, the Windows operating system displays a blue screen with the error code on the screen. These error codes

Quickly get started with Python drawing: code example for drawing Bingdundun Python is an easy-to-learn and powerful programming language. By using Python's drawing library, we can easily realize various drawing needs. In this article, we will use Python's drawing library matplotlib to draw a simple graph of ice. Bingdundun is a cute panda who is very popular among children. First, we need to install the matplotlib library. You can do this by running in the terminal

What happens when the desktop layout is locked? When using the computer, sometimes we may encounter the situation where the desktop layout is locked. This problem means that we cannot freely adjust the position of desktop icons or change the desktop background. So, what exactly is going on when it says that the desktop layout is locked? 1. Understand the desktop layout and locking functions. First, we need to understand the two concepts of desktop layout and desktop locking. Desktop layout refers to the arrangement of various elements on the desktop, including shortcuts, folders, widgets, etc. we can be free

As a programmer, I get excited about tools that simplify the coding experience. With the help of artificial intelligence tools, we can generate demo code and make necessary modifications as per the requirement. The newly introduced Copilot tool in Visual Studio Code allows us to create AI-generated code with natural language chat interactions. By explaining functionality, we can better understand the meaning of existing code. How to use Copilot to generate code? To get started, we first need to get the latest PowerPlatformTools extension. To achieve this, you need to go to the extension page, search for "PowerPlatformTool" and click the Install button

Working with files in the Linux operating system requires the use of various commands and techniques that enable developers to efficiently create and execute files, code, programs, scripts, and other things. In the Linux environment, files with the extension ".a" have great importance as static libraries. These libraries play an important role in software development, allowing developers to efficiently manage and share common functionality across multiple programs. For effective software development in a Linux environment, it is crucial to understand how to create and run ".a" files. This article will introduce how to comprehensively install and configure the Linux ".a" file. Let's explore the definition, purpose, structure, and methods of creating and executing the Linux ".a" file. What is L
