Easy Tutorial
❮ Api Highlight Effect Jqueryui Examples ❯

jQuery UI API - Tabs Widget

Category

Widgets

Usage

Description: A single content area with multiple panels, each associated with a header in a list.

Version Added: 1.0

Tabs are generally used to break content into multiple sections that can be swapped to save space, similar to an accordion.

Tabs have a particular markup that must be used in order for them to work correctly:

The content of each tab panel can be defined in-page or can be loaded via Ajax. Both methods are automatically handled based on the href of the tab's anchor. By default, tabs are activated on click, but this behavior can be changed or overridden using the event option.

Here is some sample markup:

<div id="tabs">
  <ul>
    <li><a href="#fragment-1">One</a></li>
    <li><a href="#fragment-2">Two</a></li>
    <li><a href="#fragment-3">Three</a></li>
  </ul>
  <div id="fragment-1">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
  </div>
  <div id="fragment-2">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
  </div>
  <div id="fragment-3">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
  </div>
</div>

Keyboard Interaction

When the focus is on a tab, the following keyboard commands are available:

When the focus is on a panel, the following keyboard commands are available:

Theming

The Tabs Widget uses the jQuery UI CSS Framework to define its appearance and style. If you need to use styles specific to tabs, you can use the following CSS class names:

Dependencies

Additional Notes

Example

A simple jQuery UI Tabs.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Tabs Widget Demo</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>

<div id="tabs">
  <ul>
    <li><a href="#fragment-1"><span>One</span></a></li>
    <li><a href="#fragment-2"><span>Two</span></a></li>
    <li><a href="#fragment-3"><span>Three</span></a></li>
  </ul>
  <div id="fragment-1">
    <p>The first tab is active by default:</p>
    <code>$( "#tabs" ).tabs(); </code>
  </div>
  <div id="fragment-2">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
  </div>
  <div id="fragment-3">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
  </div>
</div>

<script>
$( "#tabs" ).tabs();
</script>

</body>
</html>

View Demo

❮ Api Highlight Effect Jqueryui Examples ❯