javascript - Automatically toggle html tabs -
i have following tab structure in form of form submit button on second tab. possible tabs auto-change upon condition?
<ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#home">home</a></li> <li><a data-toggle="tab" href="#menu1">menu 1</a></li> <li><a data-toggle="tab" href="#menu2">menu 2</a></li> </ul> <div class="tab-content"> <div id="home" class="tab-pane fade in active"> <h3>home</h3> <p>some content.</p> </div> <div id="menu1" class="tab-pane fade"> <h3>menu 1</h3> <p>some content in menu 1.</p> </div> <div id="menu2" class="tab-pane fade"> <h3>menu 2</h3> <p>some content in menu 2.</p> </div> </div>
it's pretty hard answer without knowing condition want or seeing code apart html structure (and without css).
i'm assuming clicking on anchors change tabs, need add ids them:
<li><a data-toggle="tab" href="#menu1" id="tab1">menu 1</a></li> <li><a data-toggle="tab" href="#menu2" id="tab2">menu 2</a></li>
and if you're using jquery like:
if(/*whatever condition want*/){ $('#tab2').click(); }
otherwise:
if(/*whatever condition want*/){ document.getelementbyid('tab2').click(); }
Comments
Post a Comment