Bootstrap Tab Plugin
Tabs were introduced inBootstrap Navigationthe chapter. In this section we will create a tab interface using data attributes.
Use
You can enable tabs in the following two ways:
-
Via data attributes:You can enable tabs by adding the data-toggle="tab" or data-toggle="pill" to the anchor text link.
add nav and nav-tabs class to the ul.
-
Via JavaScript: You can enable tabs via JavaScript:
$('#myTab a').click(function (e) { e.preventDefault() $(this).tab('show') })
The following are examples of activating tabs in different ways:
Fade effect
If you need a fade effect for tabs, add ** .fade** to each ** .tab-paneafter it. The first tab must have the .in** class added, as in the following example:
...
...
...
...
The following example shows tabs using data attributes and their fade effect:
Tutorials Point is a place for beginners in all technical areas.
This website covers most of the latest technoligies and explains
each of the technology with simple examples. You also have a
tryit editor, wherein you can edit your code and
try out different possibilities of the examples.
iOS is a mobile operating system developed and distributed by Apple
Inc. Originally released in 2007 for the iPhone, iPod Touch, and
Apple TV. iOS is derived from OS X, with which it shares the
Darwin foundation. iOS is Apple's mobile version of the
OS X operating system used on Apple computers.
jMeter is an Open Source testing software. It is 100% pure
Java application for load and performance testing.
Enterprise Java Beans (EJB) is a development architecture
for building highly scalable and robust enterprise level
applications to be deployed on J2EE compliant
Application Server such as JBOSS, Web Logic etc.

Method
$().tab: This method activates the tab element and the content container. The tab needs a data-target or an href pointing to a container node in the DOM.
...
.....
The following example shows using the ** .tab** method of the tab plugin. In the example, the second tab, iOS, is activated.
Tutorials Point is a place for beginners in all technical areas.
This website covers most of the latest technoligies and explains
each of the technology with simple examples. You also have a
tryit editor, wherein you can edit your code and
try out different possibilities of the examples.
iOS is a mobile operating system developed and distributed by Apple
Inc. Originally released in 2007 for the iPhone, iPod Touch, and
Apple TV. iOS is derived from OS X, with which it shares the
Darwin foundation. iOS is Apple's mobile version of the
OS X operating system used on Apple computers.
jMeter is an Open Source testing software. It is 100% pure
Java application for load and performance testing.
Enterprise Java Beans (EJB) is a development architecture
for building highly scalable and robust enterprise level
applications to be deployed on J2EE compliant
Application Server such as JBOSS, Web Logic etc.
Events
The following table lists the events of the tab plugin. These events can be used as hooks in functions.
| Events | Description | Example |
|---|---|---|
| show.bs.tab | This event fires on tab show, before the tab is displayed. Use it for event.target and event.relatedTarget the event on the target active tab and the previous tab. |
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) { e.target // active tab e.relatedTarget // previous tab })| onSelect | event | shown.bs.tab | This event fires before the tab is displayed. Use it forevent.target and event.relatedTarget the event on the target active tab and the previous tab. |
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
e.target // 激活选项卡
e.relatedTarget // 前一个选项卡
})
|
The following example shows the use of plugin events; it displays the current and previously visited tabs:
Active Tab:
Previous Tab:
Tutorials Point is a place for beginners in all technical areas.
This website covers most of the latest technoligies and explains
each of the technology with simple examples. You also have a
tryit editor, wherein you can edit your code and
try out different possibilities of the examples.
iOS is a mobile operating system developed and distributed by Apple
Inc. Originally released in 2007 for the iPhone, iPod Touch, and
Apple TV. iOS is derived from OS X, with which it shares the
Darwin foundation. iOS is Apple's mobile version of the
OS X operating system used on Apple computers.
jMeter is an Open Source testing software. It is 100% pure
Java application for load and performance testing.
Enterprise Java Beans (EJB) is a development architecture
for building highly scalable and robust enterprise level
applications to be deployed on J2EE compliant
Application Server such as JBOSS, Web Logic etc.
