There are many mature frameworks for JS pagination, but many small projects are not necessary to “kill the chicken with a slaughter knife”. Here we introduce a JS pagination code for your own use.
First of all, the effect is as follows.
The idea of this pagination is to first display the current page, then print 3 pages before and after the current page as the centre, and finally print the “previous” and “first” page, “last” page “ and “next page”. If the middle pages are not connected, print “…” .
The style is simply achieved using the a tag, the specific code is as follows.