Bootstrap Learn the tab page of JS plugin

Source: Internet
Author: User

A Simple tab page

Code:

[JavaScript]View Plaincopy
  1. <H1 class="page-header" >4.3 tab
  2. <ul class="Nav nav-tabs" >
  3. <li class="active" ><a href="#" >Home</a></li>
  4. <li><a href="#" >Profile</a></li>
  5. <li><a href="#" >Message</a></li>
  6. </ul>

Preview below:

To the above pre-predefined some href tag id, add a drop-down menu

[JavaScript]View Plaincopy
  1. <ul class="Nav nav-tabs" >
  2. <li><a href="#home" >Home</a></li>
  3. <li><a href="#profile" >Profile</a></li>
  4. <li><a href="#messages" >Messages</a></li>
  5. <li><a href="#settings" >Settings</a></li>
  6. <li class="dropdown" >
  7. <a href="#" data-toggle="dropdown" class="Dropdown-toggle" >test<b class="Caret" ></b></a>
  8. <ul class="Dropdown-menu" >
  9. <li ><a href="#AAA" > @tag </a></li>
  10. <li ><a href="#BBB" > @mag </a></li>
  11. </ul>
  12. </li>
  13. </ul>

Adds an attribute to the a tag in the tab data-toggle= "tab"

Then add a div to the container below and give the style class with Tab-content.

The container defines the Div, and then adds the id attribute on the DIV, corresponds to the tag ID of the href above, and adds the Tab-pane style class, one of which is the following, of course, which also adds an active style class to the default activation

<div class= "Tab-pane active" id= "Home" >

Finally, each tab can now be clicked, and the menu of the drop-down menu can be clicked, which corresponds to the label content page we defined for tab-content.

As you can see above, we can implement the tag switching and content display through the Data property.

Expanded tabbed navigation

This plugin adds a tabbed content area to the tabbed navigation component.

Usage

Start switchable tabs via JavaScript (each tab is activated separately):

$ ( ' #myTab a '). Click (< span class= "keyword" >function  (e) { E.preventdefault () $ (this). Tab ( ' show ')})     

Remove all data-toggle of the A tag and call JS

There are several ways to activate tabs individually:

$(' #myTab a[href= "#profile"]). Tab (‘Show‘)Select tab by name$ (‘#myTab A:First ' ). tab ( '  Show ' ) //Select first tab$ ( #myTab a:last). tab ( ' show ' //select Last tab$ ( '  #myTab Li:eq ( 2) A ' show ' )  Select Third tab (0-indexed)             

Simply add the page element data-toggle="tab" or data-toggle="pill" You can activate the tab or capsule navigation without having to write any JavaScript code. You ul .nav .nav-tabs can give it a Bootstrap tab style for Add and Classe, and add nav and nav-pills class to give it a capsule label page.

You can use jquery to perform the first load

<script>  $ (function () {    $ (' #myTab a:first '). tab (' Show ')  }) </script>

$ (' a[data-toggle= ' tab "]). On (' Shown.bs.tab ', function (e) {  e.target//This parameter enables you to get the tab information for activation   E.relatedtarget The information of the tab before activating})
[JavaScript]View Plaincopy < param name= "allowfullscreen" value= "false" >< param name= "wmode" value= "Transparent" >
    1. <script type="Text/javascript" >
    2. $ (' a[data-toggle= ' tab "] '). On (' shown.bs.tab ', function (e) {
    3. //e.target//Activated tab
    4. //e.relatedtarget//Previous tab
    5. Alert ("target:" +e.target);
    6. Alert ("Related:" +e.relatedtarget);
    7. })
    8. </script>

Fade in effect

For each.tab-paneAdd to.fadeLets you have a fade-in effect on a tab. The content area corresponding to the first tab must also be added.inCauses the initial content to have a fade-in effect at the same time.

<Divclass="Tab-content" ><Divclass="Tab-pane Fade in Active"Id="Home" ...</div> <div class= "Tab-pane fade" id=  "Profile", .... </div> <div class= "Tab-pane fade" id=  "messages" ... </div> <div class= "Tab-pane fade" id=  "Settings" ... </div></DIV>   

Bootstrap Learn the tab page of JS plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.