October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

jQuery UI Tabs: Create, Configure, and Load Tabs with Ajax

A practical jQuery UI Tabs guide covering required markup, local and Ajax panels, activation options, collapsible behavior, keyboard access, events, and dynamic refreshes.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

jQuery UI Tabs turns a list of linked tab labels into a single content area whose panels can be local elements or loaded remotely. Build the required list-and-panel markup, call .tabs(), then configure activation, the active index, collapsing, keyboard behavior, height, effects, and events through the widget API.

This guide covers the current API terminology. Check the jQuery UI Tabs API for the version installed in your project; the official demo currently references jQuery 3.7.1 and jQuery UI 1.14.2, but those demo assets do not guarantee compatibility with every application stack.

What jQuery UI Tabs expects

Tabs are a widget, not just a CSS pattern. The labels must be in an ordered or unordered list. Each label is an <li> containing an anchor with an href. For an in-page panel, the anchor fragment must match that panel’s id. The panels may be otherwise valid HTML elements.

<div id="account-tabs">
  <ul>
    <li><a href="#profile-panel">Profile</a></li>
    <li><a href="#security-panel">Security</a></li>
  </ul>

  <section id="profile-panel">
    <h3>Profile</h3>
    <p>Profile fields go here.</p>
  </section>
  <section id="security-panel">
    <h3>Security</h3>
    <p>Security settings go here.</p>
  </section>
</div>

<script>
  $(function () {
    $("#account-tabs").tabs();
  });
</script>

Load jQuery and jQuery UI (including the UI CSS) before this initialization. If an anchor points to an element that does not exist, the local panel relationship is broken; check the fragment and id character-for-character.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Local panels and Ajax-loaded panels

In-page content

A fragment such as #profile-panel selects content already present in the document. This is the simplest option and keeps all panel markup in the initial page.

Remote content

The API also supports remote panels. Give a tab anchor a URL rather than an in-page fragment, and jQuery UI Tabs uses that URL for Ajax loading. Remote loading has its own beforeLoad and load events, and the widget exposes a load method.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
<div id="reports-tabs">
  <ul>
    <li><a href="reports/summary.html">Summary</a></li>
    <li><a href="reports/detail.html">Details</a></li>
  </ul>
</div>

<script>
  $("#reports-tabs").tabs({
    beforeLoad: function (event, ui) {
      // Cancel a request when application conditions require it.
      // ui.jqXHR.abort();
    },
    load: function (event, ui) {
      // ui.panel contains the loaded panel.
    }
  });
</script>

Keep the remote endpoint on the same origin or configure the server and browser for the required cross-origin policy. Handle authorization, errors, and loading states in your application rather than assuming every request succeeds.

Choose activation and panel behavior

Decision Configuration Behavior
Open one tab initially active: 0 (zero-based) Opens the first tab; use another index for a different initial panel.
Start with no panel collapsible: true and active: false Allows all panels to be closed initially.
Disable tabs disabled: true or an array of tab indexes Disables every tab or only the listed indexes.
Activation trigger Default event: "click"; optionally event: "mouseover" Chooses whether activation follows a click or pointer hover.
Panel height heightStyle: "content", "auto", or "fill" Uses each panel’s content height, a common calculated height, or available filled height.
Transition show and hide Applies configured show/hide effects when panels change.
$("#account-tabs").tabs({
  active: 1,
  collapsible: true,
  disabled: [2],
  event: "click",
  heightStyle: "auto",
  show: { effect: "fade", duration: 150 },
  hide: { effect: "fade", duration: 150 }
});

The best height mode depends on the surrounding layout. content avoids forcing short panels to match a tall one; auto gives panels a common calculated height; fill is intended when the tabs should consume the available height of their container.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keyboard access and focus

jQuery UI Tabs provides keyboard interaction in addition to pointer activation. Users can move among tabs with the arrow keys, jump to the first or last tab with Home and End, and activate the focused tab with Space or Enter. The API also documents modified key combinations for tab navigation. Do not describe this widget as mouse-only, and keep visible focus styling in your theme.

React to activation and creation events

Cancel or inspect a pending change

beforeActivate runs immediately before a tab is activated and can cancel the change. Use it for validation or an unsaved-changes decision.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
$("#account-tabs").tabs({
  beforeActivate: function (event, ui) {
    if (ui.newTab.data("requires-confirmation") && !window.confirm("Continue?")) {
      event.preventDefault();
    }
  }
});

Run code after activation

activate runs after activation and any configured animation. It does not fire for the initial tab during widget creation. Use create when initialization itself must trigger code.

$("#account-tabs").tabs({
  create: function (event, ui) {
    // Runs when the widget is created.
  },
  activate: function (event, ui) {
    // Runs after a later tab change.
  }
});
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Change tabs after initialization

Use the widget method form to read or change options and to refresh the tab set:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
var tabs = $("#account-tabs").tabs();

// Read the current zero-based active index.
var current = tabs.tabs("option", "active");

// Activate the third tab.
tabs.tabs("option", "active", 2);

// Add or remove tab markup, then ask the widget to reprocess it.
tabs.tabs("refresh");

refresh() processes tabs added to or removed directly from the DOM and recomputes panel heights. Call it after changing the markup rather than expecting the widget to detect arbitrary DOM edits automatically.

Common implementation failures

  • Panel never appears: verify that a local anchor such as #security-panel has exactly one matching id="security-panel".
  • Wrong tab opens: remember that active is zero-based, so 0 means the first tab.
  • All panels cannot be closed: set collapsible: true; setting active: false alone is not sufficient.
  • New tabs are ignored: add the markup, then call refresh().
  • Code does not run on the first panel: bind initialization logic to create; activate is for subsequent activation.
  • Ajax tab stays empty: inspect the network response, URL, permissions, and same-origin or CORS configuration, then use beforeLoad and load to observe the request lifecycle.

Appearance and supported examples

The widget’s visual presentation comes from jQuery UI’s CSS and theme classes; you can override those styles to match your application without changing the tab contract. The official jQuery UI Tabs demo shows default tabs, collapsible content, Ajax content, mouseover activation, dynamic manipulation, sortable tabs, and vertical tabs.

For projects pinned to older releases, compare the versioned references for jQuery UI 1.11 Tabs and jQuery UI 1.10 Tabs with the current Tabs API before relying on an option or event.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.