简体   繁体   中英

How to limit the number of visible pages in pagination with (JavaScript-Jquery)

I want to create a page layout without using a plugin.

The current page is like this and brings up all the pages. 在此处输入图像描述

But I want the page to show me that way.

in page 1

1 2 3 4 5 ... // selected 1

in page 2

1 2 3 4 5 6 ... //selected 2

in page 3

1 2 3 4 5 6 7 ... //selected 3

... in page 7

3 4 5 6 7 8 9 10 11 ... // selected 7

The Html code is written as follows

<nav>
        <ul data="@Model.TotalPage" data-id="@Model.CurrentPageNumber" class="pagination justify-content-center">
            @{
                for (int i = 1; i <= Model.TotalPage; i++)
                {
                    <li class="page-item @(i == Model.CurrentPageNumber ? "active" : "")">
                        <a class="bPageNumber page-link">@i</a>
                    </li>
                }
            }
        </ul>
</nav>

I think wrap both component in a single component like pagesComponent Slider // it may be your pagination

"When Pages component will render it will pass the hard core data to slider like page component 1

page component 1? slider will be 1,2,3,4: page compoenent 2? slider will be 1,2,3,4,5,6,7,8 and so one "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM