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