GithubHelp home page GithubHelp logo

hamedil / mytabs.js Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 22 KB

jQuery lightweight plugin that adds the tabs functionality to your website using url hash

Home Page: http://www.hamedadil.com/mytabs-js

License: GNU General Public License v3.0

HTML 38.39% CSS 11.73% JavaScript 49.88%
hashtag tabs jquery-plugin

mytabs.js's Introduction


myTabs.js is a simple, easy-to-style jQuery tabbing plugin to switch between tabbed content by clicking on the associated tab navigation. Also supports hashChange event that allows to open tabs by passing hash on url.

How to use it:

  1. Create the tabbed content sections as follow.
<div class="myTabs_container">
  <div class="myTabs_contents tabs-container" data-contents="tab1">
    Tab 1
  </div>
  <div class="myTabs_contents tabs-container" data-contents="tab2">
    Tab 2
  </div>
  <div class="myTabs_contents tabs-container" data-contents="tab3">
    Tab 3
  </div>
  ...
</div>
  1. Create the tab navigation as follow.
    You can add as many as you want of tabs, Just make sure that 'data-contents' & 'data-switch' have the same value.
<ul class="myTabs">
  <li><a data-switch="tab1" class="myTabs_switch default" href="#tab1">Tab 1</a></li>
  <li><a data-switch="tab2" class="myTabs_switch" href="#tab2">Tab 2</a></li>
  <li><a data-switch="tab3" class="myTabs_switch" href="#tab3">Tab 3</a></li>
  ...
</ul>
  1. Activate the plugin by calling the function on the 'myTabs_container' element.
$('#myTabs_container').myTabs('index');

Where (index) is the page url that you want this plugin to work in. For Example: if you have this url: example.com/mypage then you can pass 'mypage' to the function like this:-

$('#myTabs_container').myTabs('mypage');

Same thing goes for the descendant pages:-
For: example.com/mypage/mychildpage , use:-

$('#myTabs_container').myTabs('mychildpage');

And so on ..

  1. Customize the tabs interface using your own CSS styles.
.tabs-container {
  min-height: 30px;
  background-color: rgb(255, 255, 255);
  border-width: 1px;
  border-style: solid;
  border-color: rgb(236, 236, 236);
  border-image: initial;
  padding: 20px;
}

.myTabs_contents { display: none; }

.myTabs_contents.active { display: block; }

.myTabs {
  list-style: none;
  margin: 0;
  padding: 0;
  margin-left: -15px;
  margin-right: -15px;
}

.myTabs a.myTabs_switch {
  display: block;
  padding: 12px;
  background-color: #fbfbfb;
  border-bottom: 1px solid #f1f1f1;
  color: #303050;
}

.myTabs li:last-of-type a.myTabs_switch { border-bottom: 0; }

.myTabs a.myTabs_switch.active {
  background-color: #efefef;
  border-left: 2px solid #00a8ff;
  border-bottom: 0;
}

.myTabs a.myTabs_switch:hover {
  color: #fbfbfb;
  background-color: #00a8ff;
}

One more idea:
To select the default switch that will be activated (shown) when the page is loaded add '.default' css class to the switch that you want it to be active when the page is loaded.
<li><a data-switch="tab1" class="myTabs_switch default" href="#tab1">Tab 1</a></li>

PS: I did not create this documentation my self, Thankfully these guys created it for me. THANK YOU ๐Ÿ‘

mytabs.js's People

Contributors

hamedil avatar

Stargazers

 avatar Exil avatar

Watchers

 avatar

Forkers

cnxtech

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.