</div>
<hr>
<h2>Using bootstrap-tab.js</h2>
- <p>Enable tabbable tabs via javascript:</p>
- <pre class="prettyprint linenums">$('#myTab').tab('show')</pre>
+ <p>Enable tabbable tabs via javascript (each tab needs to be activated individually):</p>
+ <pre class="prettyprint linenums">
+ $('#myTab a').click(function (e) {
+ e.preventDefault();
+ $(this).tab('show');
+ })</pre>
+ <p>You can activate individual tabs in several ways:</p>
+ <pre class="prettyprint linenums">
-$('#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').tab('show'); //Select third tab (0-indexed)
++$('#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').tab('show'); // Select third tab (0-indexed)
+ </pre>
<h3>Markup</h3>
- <p>You can activate a tab or pill navigation without writing any javascript by simply specifying <code>data-toggle="tab"</code> or <code>data-toggle="pill"</code> on an element.</p>
+ <p>You can activate a tab or pill navigation without writing any javascript by simply specifying <code>data-toggle="tab"</code> or <code>data-toggle="pill"</code> on an element. Adding the <code>nav</code> and <code>nav-tabs</code> classes to the tab <code>ul</code> will apply the bootstrap tab styling.</p>
<pre class="prettyprint linenums">
<ul class="nav nav-tabs">
<li><a href="#home" data-toggle="tab">Home</a></li>
<h3>Methods</h3>
<h4>$().tab</h4>
<p>
-- Activates a tab element and content container. Tab should have either a `data-target` or an `href` targeting a container node in the dom.
++ Activates a tab element and content container. Tab should have either a <code>data-target</code> or an <code>href</code> targeting a container node in the DOM.
</p>
<pre class="prettyprint linenums">
- <ul class="nav nav-tabs">
+ <ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#home">Home</a></li>
<li><a href="#profile">Profile</a></li>
<li><a href="#messages">Messages</a></li>
<script>
$(function () {
- $('.tabs a:last').tab('show')
- $('#myTab a:last').tab('show')
++ $('#myTab a:last').tab('show');
})
</script></pre>
<h3>Events</h3>