In twitter bootstrap js tabs i have to add a class "active" to a li element.
I obtain the hash from the url. I apply the class active to the tab but it doesnt get the focus.
I want to make the second tab active when the url have a certain hash.
Source code: http://jsfiddle.net/Chumillas/dU458/#example
$(document). ready(function(){ activaTab('aaa'); }); function activaTab(tab){ $('. tab-pane a[href="#' + tab + '"]'). tab('show'); };
To make the tabs toggleable, add the data-toggle="tab" attribute to each link. Then add a .tab-pane class with a unique ID for every tab and wrap them inside a <div> element with class .tab-content .
removeClass('ep_s-click1'). addClass('ep_s1'); }} } }); if i use selected: 0 it will set up the first tab as active but it will now go through the if (theSelectedTab2 == 0) statement and go through adding those classes. if after the page loads i click on those tabs the script works perfect.
var selectedTab = $("#TabList"). tabs(). data("selected. tabs");
Also with latest bootstrap-tab.js, you can use following call to select active tab.
Nav Sample:
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1" data-toggle="tab">Tab 1</a></li>
<li><a href="#tab2" data-toggle="tab">Tab 2</a></li>
<li><a href="#tab3" data-toggle="tab">Tab 3</a></li>
</ul>
Get object with link and display call:
$('a[href="#tab2"]').tab('show');
Bests, G.
source:Twitter Bootstrap
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With