jquery - Bootstrap 3 Make First Tab Active By Clicking From Outside Button -


can please let me know how can make bootstrap first tab active again clickicking button outside of tab-navs?

i alredy tried this

<!-- nav tabs --> <ul class="nav nav-tabs" role="tablist">   <li role="presentation" class="active"><a href="#home" role="tab" data-toggle="tab">home</a></li>   <li role="presentation"><a href="#profile" role="tab" data-toggle="tab">profile</a></li>   <li role="presentation"><a href="#messages" role="tab" data-toggle="tab">messages</a></li>   <li role="presentation"><a href="#settings" role="tab" data-toggle="tab">settings</a></li> </ul>  <!-- tab panes --> <div class="tab-content">   <div role="tabpanel" class="tab-pane active" id="home">...</div>   <div role="tabpanel" class="tab-pane" id="profile">...</div>   <div role="tabpanel" class="tab-pane" id="messages">...</div>   <div role="tabpanel" class="tab-pane" id="settings">...</div> </div> 

js:

$('#btnreview').click(function(){   $(".tab-content").removeclass("active");   $(".tab-content:first-child").addclass("active"); }); 

and

$('#btnreview').click(function(){   $(".nav-tabs").removeclass("active");   $(".nav-tabs:first-child").addclass("active"); }); 

but both not doing job! thanks

you can use .tab() method this:

$('#btnreview').click(function(){     $('#tab1').tab('show') }); 

i added directly id tab <a>, can play selectors:

<li role="presentation" class="active"><a href="#home" role="tab" data-toggle="tab" id="tab1">home</a></li> 

from bootstrap tab docs:

$().tab

activates tab element , content container. tab should have either data-target or href targeting container node in dom.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -