Lightweight jQuery Plugin For Tab Content - Tabs.js

File Size: 8.59 KB
Views Total: 1713
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Lightweight jQuery Plugin For Tab Content - Tabs.js

Yet another jQuery plugin for tab content where the users are able to swap between tabbed content by clicking tabs.

How to use it:

1. The required HTML structure for the tab content.

<div class="tabs--block" id="tabs">
  <div class="tabs--header">
    <div class="tab-head"><a href="javascript:;" rel="tab_1a"><span>tab_1</span></a></div>
    <div class="tab-head"><a href="javascript:;" rel="tab_2a"><span>tab_2</span></a></div>
    <div class="tab-head"><a href="javascript:;" rel="tab_3a"><span>tab_3</span></a></div>
  <div class="tabs--content">
    <div class="tab-content" id="tab_1a">
      <p>Tab 1 content</p>
    <div class="tab-content" id="tab_2a">
      <p>Tab 2 content</p>
    <div class="tab-content" id="tab_3a">
      <p>Tab 3 content</p>

2. Include jQuery library and the jQuery Tabs.js script at the bottom of the page.

<script src="//"></script>
<script src="tabs.js"></script>

3. The JavaScript to create tabs for the tabbed content.


4. Style the plugin whatever you like.

.tabs--block {
  overflow: hidden;
  margin-top: 30px

.tabs--header {
  font-size: 0;
  box-shadow: 0 -1px 0 #999 inset;
  white-space: nowrap

.tab-head {
  display: inline-block;
  vertical-align: middle;
  font-size: 1rem

.tab-head:last-child { border-right: 1px solid #999 }

.tab-head a {
  display: block;
  height: 50px;
  line-height: 50px;
  padding: 0 20px;
  text-decoration: none;
  border-left: 1px solid #999;
  border-top: 1px solid #999;
  border-bottom: 1px solid #999;
  background: #eee

.tab-head__active a {
  background: #fff;
  color: #ccc;
  border-bottom: 1px solid #fff

.tab-head a span {
  display: inline-block;
  vertical-align: middle

.tabs--content {
  border: 1px solid #999;
  border-top: 0;
  padding: 10px 15px

.tab-content { display: none }

.tab-content h2 { text-transform: uppercase }

5. The plugin also allows you to perform actions on each tab change.

    'ALL': function(){
      // ...
    'tab_2a': function(){
      // ...
    'tab_3a': function(){
      // ...

This awesome jQuery plugin is developed by tishinskiy. For more Advanced Usages, please check the demo page or visit the official website.