webdevpuneet.com

Bootstrap Pagination with Page Jump Input — Free Snippet

Bootstrap Pagination with Page Jump Input · Navigation · Plain HTML, CSS & JS · Live preview

CategoryNavigation

Copy & paste

Source Code

<div class="container py-5 text-center">
  <p class="text-muted small mb-3" id="bspageInfo">Page 1 of 24</p>
  <nav aria-label="Page navigation">
    <ul class="pagination justify-content-center bspage-list" id="bspageList"></ul>
  </nav>
  <div class="d-inline-flex align-items-center gap-2 mt-3">
    <span class="small text-muted">Jump to page</span>
    <input type="number" class="form-control form-control-sm" id="bspageInput" style="width:70px" min="1" max="24">
    <button class="btn btn-sm btn-dark" id="bspageGo">Go</button>
  </div>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month, 7 days free), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Real Bootstrap 5.3 pagination component, loaded from the actual CDN
Windowed page numbers with "…" gaps instead of listing every page
Page-jump input clamped to the valid range, submittable via button or Enter key
Prev/Next automatically disable at the first and last page
Regenerates the whole page-number window from scratch on every navigation
Scales to any total page count by changing one constant

About this UI Snippet

Bootstrap Pagination with Page Jump Input — HTML, CSS & JavaScript

Screenshot of the Bootstrap Pagination with Page Jump Input snippet rendered live

Listing all 24 pages of a real result set would make Bootstrap's .pagination component unusably wide. This snippet builds a windowed pager on top of real Bootstrap 5.3 pagination markup: it always shows the first page, the last page, the current page, and one neighbor on each side, with "…" filling any gap — the same windowing shape used by most real-world paginated interfaces, generated fresh from a pageWindow() function on every navigation rather than a fixed set of links.

Alongside the pager, a small "Jump to page" number input lets a visitor skip straight to any page by number — clamped to the valid 1–24 range and submittable with either the Go button or Enter — for the common case where the page you want is many pages away from your current position and clicking Next repeatedly isn't reasonable.

Step by step

How to Use

  1. 1
    Load the snippetClick the snippet in the sidebar Library tab. The preview loads on page 1 of 24.
  2. 2
    Click through pagesClick a page number, or Prev/Next — the windowed page list recalculates around your new position.
  3. 3
    Jump to a distant pageType "18" into the jump input and click Go (or press Enter) — it navigates straight there.
  4. 4
    Try an out-of-range valueType "99" and click Go — it clamps to the last real page (24) instead of breaking.
  5. 5
    Adjust the totalChange the TOTAL constant in the JS panel to match your real result count.

Real-world uses

Common Use Cases

Search results and data table pagination
Any result set with more than a handful of pages benefits from windowed pagination plus a direct jump for large result sets.
Learning the windowed-pagination pattern
A clean, from-scratch implementation of the ellipsis-windowing technique used by most production pagers.
Admin panels listing many records
Pair with the Bootstrap Admin Dashboard snippet's orders table for a fully paginated records view.
Any long, page-based content archive
Blog archives, product catalogs, or documentation indexes that span dozens of pages.

Got questions?

Frequently Asked Questions

Yes — it uses Bootstrap 5.3's actual .pagination, .page-item, and .page-link classes loaded from the CDN; only the page-number generation logic and the jump input are custom.

pageWindow() always includes page 1, the last page, the current page, and one page on either side of it, sorts them, and inserts a "…" wherever there's a gap larger than 1 between consecutive included pages.

The jump handler clamps the typed value to between 1 and the total page count with Math.min/Math.max, so an out-of-range or negative number always lands on a valid page instead of breaking.

Yes — replace the TOTAL constant with your real page count (e.g. from an API response), and wire goTo() to actually fetch/render that page's data instead of just updating the display.

Yes — a keydown listener on the input triggers the same Go logic when the Enter key is pressed, so keyboard-only use works identically to clicking.

Yes. While the Bootstrap Pagination with Page Jump Input snippet gives you one pattern to copy, the free Responsive Navbar Builder at webdevpuneet.com/navbar-builder/ designs a whole navigation bar: logo, links and dropdown menus, a mobile hamburger menu (dropdown panel, slide-in drawer or full screen) and a scroll effect (sticky, shrink, hide on scroll or transparent). It has six presets, a live preview that runs the real code, and exports HTML + CSS + vanilla JS, React, Tailwind, Vue 3 or Angular — or you can click Fork & Edit to keep editing it in My Code.