Code example for implementing paging effect using native javascript

Source: Internet
Author: User
This article mainly introduces the paging Effect of native javascript, which has some reference value, if you are interested, you can refer to this article to introduce in detail the paging Effect of native javascript, which has some reference value. If you are interested, you can refer

With the rapid development of the front-end industry in recent years, various emerging new frameworks and methods have made us a little dazzled.

Recently, I was just idle, so I have nothing to do with preparing the basic javascript For the zookeeper front-end. It is purely a trainer and I will write a page. By the way, I will share it with you.

Function pageFunc (conf) {this. myFunc = conf. click // the method that the user clicks to execute this. total = conf. total; // total number of pages this. currentPage = 1; // current page number this. init () // initialization} pageFunc. prototype. init = function () {var total = this. total, currentPage = this. currentPage, _ this = this; listeners = {'setwh': function (opts) {_ this. aClick (opts. src) return false ;}}; listenersPre = {'lmw-pre': function (opts) {_ this. prevClick () return false ;}}; listenersAdd = {'lmw-add': function (opts) {_ this. addClick () return false ;}}; var rootele = this. createPage (1, total); document. getElementById ('page-coat '). innerHTML = rootele $ on (document. getElementById ('page-coat'), ['click'], listeners); // click the tag $ on (document. getElementById ('page-coat'), ['click'], listenersPre); // click the previous page $ on (document. getElementById ('page-coat'), ['click'], listenersAdd); // click the next page} // create an HTML pageFunc paging structure string. prototype. createPage = function (page, total) {var str = '$ {page}' for (var I = 1; I <= 3; I ++) {if (page-I> 1) {str = '$ {page-I}' + str} if (page + I
 
  
1) {str = '...' + str}; if (page + 4
  
   
1) {str = 'previous page 1' + str}; if (page
   
    

Usage:

 
      Paging Effect  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.