Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery and twitter bootstrap make active tab doesnt work

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

like image 366
Otto Avatar asked Dec 03 '11 14:12

Otto


People also ask

How do you make a bootstrap tab active using jquery?

$(document). ready(function(){ activaTab('aaa'); }); function activaTab(tab){ $('. tab-pane a[href="#' + tab + '"]'). tab('show'); };

How to make tab active in bootstrap?

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 .

How do I make the first tab active in jquery?

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.

How do I know which tab is selected in jquery?

var selectedTab = $("#TabList"). tabs(). data("selected. tabs");


1 Answers

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

like image 145
Guvener Gokce Avatar answered Nov 03 '22 11:11

Guvener Gokce