Open a specific bootstrap tab on page load using jQuery












0















I try to open a Bootstrap v.3 tab on page load using jQuery. I tried the



$('#activeTab3').addClass("active"); 


and



$('#activeTab3').tab('show')


which colors the button in the navigation list, but the content which is shown is belongs to the 1st tab.



I also tried:



$("#mytabs").tabs({
active: 1
});


but I get an error that tabs isn't a function..






$('#activeTab3').addClass("active");

//$('#activeTab3').tab('show')


/*
$("#mytabs").tabs({
active: 1
});
*/

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

<div class="container">
<div class="row mtop-2">
<div class="col-md-12 col-xs-10">
<ul class="nav nav-pills" role="tablist" id="mytabs">
<li role="presentation" id="activeTab1"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
<li role="presentation" id="activeTab2"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
<li role="presentation" id="activeTab3"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
</ul>

<div class="tab-content">

<div role="tabpanel" class="tab-pane active" id="tab1">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
<i class="fa fa-plus mright-1"></i> panel 1-1
</a>
</h4>
</div>
<div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
<div class="panel-body">
<div class="row mtop-2">
.... panel 1-1
</div>
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
<i class="fa fa-edit mright-1"></i> panel 1-2
</a>
</h4>
</div>
<div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
<div class="panel-body">
.... panel 1-3
</div>
</div>
</div>
</div>
</div>

<div role="tabpanel" class="tab-pane" id="tab2">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
<i class="fa fa-plus mright-1"></i> panel 2-1
</a>
</h4>
</div>
<div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
<div class="panel-body">
panel 2-1
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
<i class="fa fa-edit mright-1"></i> panel 2-2
</a>
</h4>
</div>
<div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
<div class="panel-body">
panel 2-2

</div>
</div>
</div>
</div>
</div>

<div role="tabpanel" class="tab-pane" id="tab3">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
<i class="fa fa-plus mright-1"></i> panel 3-1
</a>
</h4>
</div>
<div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
<div class="panel-body">
panel 3-1
</div>
</div>
</div>

<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
<i class="fa fa-edit mright-1"></i> panel 3-2
</a>
</h4>
</div>
<div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
<div class="panel-body">
panel 3-2
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>












share|improve this question



























    0















    I try to open a Bootstrap v.3 tab on page load using jQuery. I tried the



    $('#activeTab3').addClass("active"); 


    and



    $('#activeTab3').tab('show')


    which colors the button in the navigation list, but the content which is shown is belongs to the 1st tab.



    I also tried:



    $("#mytabs").tabs({
    active: 1
    });


    but I get an error that tabs isn't a function..






    $('#activeTab3').addClass("active");

    //$('#activeTab3').tab('show')


    /*
    $("#mytabs").tabs({
    active: 1
    });
    */

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

    <div class="container">
    <div class="row mtop-2">
    <div class="col-md-12 col-xs-10">
    <ul class="nav nav-pills" role="tablist" id="mytabs">
    <li role="presentation" id="activeTab1"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
    <li role="presentation" id="activeTab2"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
    <li role="presentation" id="activeTab3"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
    </ul>

    <div class="tab-content">

    <div role="tabpanel" class="tab-pane active" id="tab1">
    <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
    <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingOne">
    <h4 class="panel-title">
    <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
    <i class="fa fa-plus mright-1"></i> panel 1-1
    </a>
    </h4>
    </div>
    <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
    <div class="panel-body">
    <div class="row mtop-2">
    .... panel 1-1
    </div>
    </div>
    </div>
    </div>

    <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingTwo">
    <h4 class="panel-title">
    <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
    <i class="fa fa-edit mright-1"></i> panel 1-2
    </a>
    </h4>
    </div>
    <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
    <div class="panel-body">
    .... panel 1-3
    </div>
    </div>
    </div>
    </div>
    </div>

    <div role="tabpanel" class="tab-pane" id="tab2">
    <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
    <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingOne">
    <h4 class="panel-title">
    <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
    <i class="fa fa-plus mright-1"></i> panel 2-1
    </a>
    </h4>
    </div>
    <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
    <div class="panel-body">
    panel 2-1
    </div>
    </div>
    </div>

    <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingTwo">
    <h4 class="panel-title">
    <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
    <i class="fa fa-edit mright-1"></i> panel 2-2
    </a>
    </h4>
    </div>
    <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
    <div class="panel-body">
    panel 2-2

    </div>
    </div>
    </div>
    </div>
    </div>

    <div role="tabpanel" class="tab-pane" id="tab3">
    <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
    <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingOne">
    <h4 class="panel-title">
    <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
    <i class="fa fa-plus mright-1"></i> panel 3-1
    </a>
    </h4>
    </div>
    <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
    <div class="panel-body">
    panel 3-1
    </div>
    </div>
    </div>

    <div class="panel panel-default">
    <div class="panel-heading" role="tab" id="headingTwo">
    <h4 class="panel-title">
    <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
    <i class="fa fa-edit mright-1"></i> panel 3-2
    </a>
    </h4>
    </div>
    <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
    <div class="panel-body">
    panel 3-2
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>












    share|improve this question

























      0












      0








      0








      I try to open a Bootstrap v.3 tab on page load using jQuery. I tried the



      $('#activeTab3').addClass("active"); 


      and



      $('#activeTab3').tab('show')


      which colors the button in the navigation list, but the content which is shown is belongs to the 1st tab.



      I also tried:



      $("#mytabs").tabs({
      active: 1
      });


      but I get an error that tabs isn't a function..






      $('#activeTab3').addClass("active");

      //$('#activeTab3').tab('show')


      /*
      $("#mytabs").tabs({
      active: 1
      });
      */

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

      <div class="container">
      <div class="row mtop-2">
      <div class="col-md-12 col-xs-10">
      <ul class="nav nav-pills" role="tablist" id="mytabs">
      <li role="presentation" id="activeTab1"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
      <li role="presentation" id="activeTab2"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
      <li role="presentation" id="activeTab3"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
      </ul>

      <div class="tab-content">

      <div role="tabpanel" class="tab-pane active" id="tab1">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
      <i class="fa fa-plus mright-1"></i> panel 1-1
      </a>
      </h4>
      </div>
      <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
      <div class="panel-body">
      <div class="row mtop-2">
      .... panel 1-1
      </div>
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
      <i class="fa fa-edit mright-1"></i> panel 1-2
      </a>
      </h4>
      </div>
      <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
      <div class="panel-body">
      .... panel 1-3
      </div>
      </div>
      </div>
      </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab2">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
      <i class="fa fa-plus mright-1"></i> panel 2-1
      </a>
      </h4>
      </div>
      <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
      <div class="panel-body">
      panel 2-1
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
      <i class="fa fa-edit mright-1"></i> panel 2-2
      </a>
      </h4>
      </div>
      <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
      <div class="panel-body">
      panel 2-2

      </div>
      </div>
      </div>
      </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab3">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
      <i class="fa fa-plus mright-1"></i> panel 3-1
      </a>
      </h4>
      </div>
      <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
      <div class="panel-body">
      panel 3-1
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
      <i class="fa fa-edit mright-1"></i> panel 3-2
      </a>
      </h4>
      </div>
      <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
      <div class="panel-body">
      panel 3-2
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>












      share|improve this question














      I try to open a Bootstrap v.3 tab on page load using jQuery. I tried the



      $('#activeTab3').addClass("active"); 


      and



      $('#activeTab3').tab('show')


      which colors the button in the navigation list, but the content which is shown is belongs to the 1st tab.



      I also tried:



      $("#mytabs").tabs({
      active: 1
      });


      but I get an error that tabs isn't a function..






      $('#activeTab3').addClass("active");

      //$('#activeTab3').tab('show')


      /*
      $("#mytabs").tabs({
      active: 1
      });
      */

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

      <div class="container">
      <div class="row mtop-2">
      <div class="col-md-12 col-xs-10">
      <ul class="nav nav-pills" role="tablist" id="mytabs">
      <li role="presentation" id="activeTab1"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
      <li role="presentation" id="activeTab2"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
      <li role="presentation" id="activeTab3"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
      </ul>

      <div class="tab-content">

      <div role="tabpanel" class="tab-pane active" id="tab1">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
      <i class="fa fa-plus mright-1"></i> panel 1-1
      </a>
      </h4>
      </div>
      <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
      <div class="panel-body">
      <div class="row mtop-2">
      .... panel 1-1
      </div>
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
      <i class="fa fa-edit mright-1"></i> panel 1-2
      </a>
      </h4>
      </div>
      <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
      <div class="panel-body">
      .... panel 1-3
      </div>
      </div>
      </div>
      </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab2">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
      <i class="fa fa-plus mright-1"></i> panel 2-1
      </a>
      </h4>
      </div>
      <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
      <div class="panel-body">
      panel 2-1
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
      <i class="fa fa-edit mright-1"></i> panel 2-2
      </a>
      </h4>
      </div>
      <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
      <div class="panel-body">
      panel 2-2

      </div>
      </div>
      </div>
      </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab3">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
      <i class="fa fa-plus mright-1"></i> panel 3-1
      </a>
      </h4>
      </div>
      <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
      <div class="panel-body">
      panel 3-1
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
      <i class="fa fa-edit mright-1"></i> panel 3-2
      </a>
      </h4>
      </div>
      <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
      <div class="panel-body">
      panel 3-2
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>








      $('#activeTab3').addClass("active");

      //$('#activeTab3').tab('show')


      /*
      $("#mytabs").tabs({
      active: 1
      });
      */

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

      <div class="container">
      <div class="row mtop-2">
      <div class="col-md-12 col-xs-10">
      <ul class="nav nav-pills" role="tablist" id="mytabs">
      <li role="presentation" id="activeTab1"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
      <li role="presentation" id="activeTab2"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
      <li role="presentation" id="activeTab3"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
      </ul>

      <div class="tab-content">

      <div role="tabpanel" class="tab-pane active" id="tab1">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
      <i class="fa fa-plus mright-1"></i> panel 1-1
      </a>
      </h4>
      </div>
      <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
      <div class="panel-body">
      <div class="row mtop-2">
      .... panel 1-1
      </div>
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
      <i class="fa fa-edit mright-1"></i> panel 1-2
      </a>
      </h4>
      </div>
      <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
      <div class="panel-body">
      .... panel 1-3
      </div>
      </div>
      </div>
      </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab2">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
      <i class="fa fa-plus mright-1"></i> panel 2-1
      </a>
      </h4>
      </div>
      <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
      <div class="panel-body">
      panel 2-1
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
      <i class="fa fa-edit mright-1"></i> panel 2-2
      </a>
      </h4>
      </div>
      <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
      <div class="panel-body">
      panel 2-2

      </div>
      </div>
      </div>
      </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab3">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
      <i class="fa fa-plus mright-1"></i> panel 3-1
      </a>
      </h4>
      </div>
      <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
      <div class="panel-body">
      panel 3-1
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
      <i class="fa fa-edit mright-1"></i> panel 3-2
      </a>
      </h4>
      </div>
      <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
      <div class="panel-body">
      panel 3-2
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>





      $('#activeTab3').addClass("active");

      //$('#activeTab3').tab('show')


      /*
      $("#mytabs").tabs({
      active: 1
      });
      */

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
      <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

      <div class="container">
      <div class="row mtop-2">
      <div class="col-md-12 col-xs-10">
      <ul class="nav nav-pills" role="tablist" id="mytabs">
      <li role="presentation" id="activeTab1"><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
      <li role="presentation" id="activeTab2"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
      <li role="presentation" id="activeTab3"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
      </ul>

      <div class="tab-content">

      <div role="tabpanel" class="tab-pane active" id="tab1">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
      <i class="fa fa-plus mright-1"></i> panel 1-1
      </a>
      </h4>
      </div>
      <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
      <div class="panel-body">
      <div class="row mtop-2">
      .... panel 1-1
      </div>
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
      <i class="fa fa-edit mright-1"></i> panel 1-2
      </a>
      </h4>
      </div>
      <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
      <div class="panel-body">
      .... panel 1-3
      </div>
      </div>
      </div>
      </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab2">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
      <i class="fa fa-plus mright-1"></i> panel 2-1
      </a>
      </h4>
      </div>
      <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
      <div class="panel-body">
      panel 2-1
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
      <i class="fa fa-edit mright-1"></i> panel 2-2
      </a>
      </h4>
      </div>
      <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
      <div class="panel-body">
      panel 2-2

      </div>
      </div>
      </div>
      </div>
      </div>

      <div role="tabpanel" class="tab-pane" id="tab3">
      <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingOne">
      <h4 class="panel-title">
      <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
      <i class="fa fa-plus mright-1"></i> panel 3-1
      </a>
      </h4>
      </div>
      <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
      <div class="panel-body">
      panel 3-1
      </div>
      </div>
      </div>

      <div class="panel panel-default">
      <div class="panel-heading" role="tab" id="headingTwo">
      <h4 class="panel-title">
      <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
      <i class="fa fa-edit mright-1"></i> panel 3-2
      </a>
      </h4>
      </div>
      <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
      <div class="panel-body">
      panel 3-2
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>






      javascript jquery twitter-bootstrap-3 tabs






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 6:54









      yaylitzisyaylitzis

      1,882113467




      1,882113467
























          1 Answer
          1






          active

          oldest

          votes


















          1

















          $(document).ready(function(){

          $('#mytabs a[href="#tab3"]').tab('show')

          });

          <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
          <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
          <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

          <div class="container">
          <div class="row mtop-2">
          <div class="col-md-12 col-xs-10">
          <ul class="nav nav-pills" role="tablist" id="mytabs">
          <li role="presentation" ><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
          <li role="presentation"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
          <li role="presentation"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
          </ul>

          <div class="tab-content">

          <div role="tabpanel" class="tab-pane active" id="tab1">
          <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
          <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="headingOne">
          <h4 class="panel-title">
          <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
          <i class="fa fa-plus mright-1"></i> panel 1-1
          </a>
          </h4>
          </div>
          <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
          <div class="panel-body">
          <div class="row mtop-2">
          .... panel 1-1
          </div>
          </div>
          </div>
          </div>

          <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="headingTwo">
          <h4 class="panel-title">
          <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
          <i class="fa fa-edit mright-1"></i> panel 1-2
          </a>
          </h4>
          </div>
          <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
          <div class="panel-body">
          .... panel 1-3
          </div>
          </div>
          </div>
          </div>
          </div>

          <div role="tabpanel" class="tab-pane" id="tab2">
          <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
          <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="headingOne">
          <h4 class="panel-title">
          <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
          <i class="fa fa-plus mright-1"></i> panel 2-1
          </a>
          </h4>
          </div>
          <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
          <div class="panel-body">
          panel 2-1
          </div>
          </div>
          </div>

          <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="headingTwo">
          <h4 class="panel-title">
          <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
          <i class="fa fa-edit mright-1"></i> panel 2-2
          </a>
          </h4>
          </div>
          <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
          <div class="panel-body">
          panel 2-2

          </div>
          </div>
          </div>
          </div>
          </div>

          <div role="tabpanel" class="tab-pane" id="tab3">
          <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
          <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="headingOne">
          <h4 class="panel-title">
          <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
          <i class="fa fa-plus mright-1"></i> panel 3-1
          </a>
          </h4>
          </div>
          <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
          <div class="panel-body">
          panel 3-1
          </div>
          </div>
          </div>

          <div class="panel panel-default">
          <div class="panel-heading" role="tab" id="headingTwo">
          <h4 class="panel-title">
          <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
          <i class="fa fa-edit mright-1"></i> panel 3-2
          </a>
          </h4>
          </div>
          <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
          <div class="panel-body">
          panel 3-2
          </div>
          </div>
          </div>
          </div>
          </div>
          </div>
          </div>
          </div>
          </div>





          Use $('#mytabs a[href="#tab3"]').tab('show') to select tab using the tab css id and href css id.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441935%2fopen-a-specific-bootstrap-tab-on-page-load-using-jquery%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1

















            $(document).ready(function(){

            $('#mytabs a[href="#tab3"]').tab('show')

            });

            <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
            <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

            <div class="container">
            <div class="row mtop-2">
            <div class="col-md-12 col-xs-10">
            <ul class="nav nav-pills" role="tablist" id="mytabs">
            <li role="presentation" ><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
            <li role="presentation"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
            <li role="presentation"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
            </ul>

            <div class="tab-content">

            <div role="tabpanel" class="tab-pane active" id="tab1">
            <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
            <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="headingOne">
            <h4 class="panel-title">
            <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
            <i class="fa fa-plus mright-1"></i> panel 1-1
            </a>
            </h4>
            </div>
            <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
            <div class="panel-body">
            <div class="row mtop-2">
            .... panel 1-1
            </div>
            </div>
            </div>
            </div>

            <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="headingTwo">
            <h4 class="panel-title">
            <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
            <i class="fa fa-edit mright-1"></i> panel 1-2
            </a>
            </h4>
            </div>
            <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
            <div class="panel-body">
            .... panel 1-3
            </div>
            </div>
            </div>
            </div>
            </div>

            <div role="tabpanel" class="tab-pane" id="tab2">
            <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
            <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="headingOne">
            <h4 class="panel-title">
            <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
            <i class="fa fa-plus mright-1"></i> panel 2-1
            </a>
            </h4>
            </div>
            <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
            <div class="panel-body">
            panel 2-1
            </div>
            </div>
            </div>

            <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="headingTwo">
            <h4 class="panel-title">
            <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
            <i class="fa fa-edit mright-1"></i> panel 2-2
            </a>
            </h4>
            </div>
            <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
            <div class="panel-body">
            panel 2-2

            </div>
            </div>
            </div>
            </div>
            </div>

            <div role="tabpanel" class="tab-pane" id="tab3">
            <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
            <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="headingOne">
            <h4 class="panel-title">
            <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
            <i class="fa fa-plus mright-1"></i> panel 3-1
            </a>
            </h4>
            </div>
            <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
            <div class="panel-body">
            panel 3-1
            </div>
            </div>
            </div>

            <div class="panel panel-default">
            <div class="panel-heading" role="tab" id="headingTwo">
            <h4 class="panel-title">
            <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
            <i class="fa fa-edit mright-1"></i> panel 3-2
            </a>
            </h4>
            </div>
            <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
            <div class="panel-body">
            panel 3-2
            </div>
            </div>
            </div>
            </div>
            </div>
            </div>
            </div>
            </div>
            </div>





            Use $('#mytabs a[href="#tab3"]').tab('show') to select tab using the tab css id and href css id.






            share|improve this answer




























              1

















              $(document).ready(function(){

              $('#mytabs a[href="#tab3"]').tab('show')

              });

              <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
              <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
              <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

              <div class="container">
              <div class="row mtop-2">
              <div class="col-md-12 col-xs-10">
              <ul class="nav nav-pills" role="tablist" id="mytabs">
              <li role="presentation" ><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
              <li role="presentation"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
              <li role="presentation"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
              </ul>

              <div class="tab-content">

              <div role="tabpanel" class="tab-pane active" id="tab1">
              <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
              <div class="panel panel-default">
              <div class="panel-heading" role="tab" id="headingOne">
              <h4 class="panel-title">
              <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
              <i class="fa fa-plus mright-1"></i> panel 1-1
              </a>
              </h4>
              </div>
              <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
              <div class="panel-body">
              <div class="row mtop-2">
              .... panel 1-1
              </div>
              </div>
              </div>
              </div>

              <div class="panel panel-default">
              <div class="panel-heading" role="tab" id="headingTwo">
              <h4 class="panel-title">
              <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
              <i class="fa fa-edit mright-1"></i> panel 1-2
              </a>
              </h4>
              </div>
              <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
              <div class="panel-body">
              .... panel 1-3
              </div>
              </div>
              </div>
              </div>
              </div>

              <div role="tabpanel" class="tab-pane" id="tab2">
              <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
              <div class="panel panel-default">
              <div class="panel-heading" role="tab" id="headingOne">
              <h4 class="panel-title">
              <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
              <i class="fa fa-plus mright-1"></i> panel 2-1
              </a>
              </h4>
              </div>
              <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
              <div class="panel-body">
              panel 2-1
              </div>
              </div>
              </div>

              <div class="panel panel-default">
              <div class="panel-heading" role="tab" id="headingTwo">
              <h4 class="panel-title">
              <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
              <i class="fa fa-edit mright-1"></i> panel 2-2
              </a>
              </h4>
              </div>
              <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
              <div class="panel-body">
              panel 2-2

              </div>
              </div>
              </div>
              </div>
              </div>

              <div role="tabpanel" class="tab-pane" id="tab3">
              <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
              <div class="panel panel-default">
              <div class="panel-heading" role="tab" id="headingOne">
              <h4 class="panel-title">
              <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
              <i class="fa fa-plus mright-1"></i> panel 3-1
              </a>
              </h4>
              </div>
              <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
              <div class="panel-body">
              panel 3-1
              </div>
              </div>
              </div>

              <div class="panel panel-default">
              <div class="panel-heading" role="tab" id="headingTwo">
              <h4 class="panel-title">
              <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
              <i class="fa fa-edit mright-1"></i> panel 3-2
              </a>
              </h4>
              </div>
              <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
              <div class="panel-body">
              panel 3-2
              </div>
              </div>
              </div>
              </div>
              </div>
              </div>
              </div>
              </div>
              </div>





              Use $('#mytabs a[href="#tab3"]').tab('show') to select tab using the tab css id and href css id.






              share|improve this answer


























                1












                1








                1










                $(document).ready(function(){

                $('#mytabs a[href="#tab3"]').tab('show')

                });

                <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
                <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

                <div class="container">
                <div class="row mtop-2">
                <div class="col-md-12 col-xs-10">
                <ul class="nav nav-pills" role="tablist" id="mytabs">
                <li role="presentation" ><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
                <li role="presentation"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
                <li role="presentation"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
                </ul>

                <div class="tab-content">

                <div role="tabpanel" class="tab-pane active" id="tab1">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
                <i class="fa fa-plus mright-1"></i> panel 1-1
                </a>
                </h4>
                </div>
                <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
                <div class="panel-body">
                <div class="row mtop-2">
                .... panel 1-1
                </div>
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
                <i class="fa fa-edit mright-1"></i> panel 1-2
                </a>
                </h4>
                </div>
                <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
                <div class="panel-body">
                .... panel 1-3
                </div>
                </div>
                </div>
                </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="tab2">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
                <i class="fa fa-plus mright-1"></i> panel 2-1
                </a>
                </h4>
                </div>
                <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
                <div class="panel-body">
                panel 2-1
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
                <i class="fa fa-edit mright-1"></i> panel 2-2
                </a>
                </h4>
                </div>
                <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
                <div class="panel-body">
                panel 2-2

                </div>
                </div>
                </div>
                </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="tab3">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
                <i class="fa fa-plus mright-1"></i> panel 3-1
                </a>
                </h4>
                </div>
                <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
                <div class="panel-body">
                panel 3-1
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
                <i class="fa fa-edit mright-1"></i> panel 3-2
                </a>
                </h4>
                </div>
                <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
                <div class="panel-body">
                panel 3-2
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>





                Use $('#mytabs a[href="#tab3"]').tab('show') to select tab using the tab css id and href css id.






                share|improve this answer
















                $(document).ready(function(){

                $('#mytabs a[href="#tab3"]').tab('show')

                });

                <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
                <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

                <div class="container">
                <div class="row mtop-2">
                <div class="col-md-12 col-xs-10">
                <ul class="nav nav-pills" role="tablist" id="mytabs">
                <li role="presentation" ><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
                <li role="presentation"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
                <li role="presentation"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
                </ul>

                <div class="tab-content">

                <div role="tabpanel" class="tab-pane active" id="tab1">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
                <i class="fa fa-plus mright-1"></i> panel 1-1
                </a>
                </h4>
                </div>
                <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
                <div class="panel-body">
                <div class="row mtop-2">
                .... panel 1-1
                </div>
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
                <i class="fa fa-edit mright-1"></i> panel 1-2
                </a>
                </h4>
                </div>
                <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
                <div class="panel-body">
                .... panel 1-3
                </div>
                </div>
                </div>
                </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="tab2">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
                <i class="fa fa-plus mright-1"></i> panel 2-1
                </a>
                </h4>
                </div>
                <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
                <div class="panel-body">
                panel 2-1
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
                <i class="fa fa-edit mright-1"></i> panel 2-2
                </a>
                </h4>
                </div>
                <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
                <div class="panel-body">
                panel 2-2

                </div>
                </div>
                </div>
                </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="tab3">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
                <i class="fa fa-plus mright-1"></i> panel 3-1
                </a>
                </h4>
                </div>
                <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
                <div class="panel-body">
                panel 3-1
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
                <i class="fa fa-edit mright-1"></i> panel 3-2
                </a>
                </h4>
                </div>
                <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
                <div class="panel-body">
                panel 3-2
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>





                Use $('#mytabs a[href="#tab3"]').tab('show') to select tab using the tab css id and href css id.






                $(document).ready(function(){

                $('#mytabs a[href="#tab3"]').tab('show')

                });

                <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
                <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

                <div class="container">
                <div class="row mtop-2">
                <div class="col-md-12 col-xs-10">
                <ul class="nav nav-pills" role="tablist" id="mytabs">
                <li role="presentation" ><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
                <li role="presentation"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
                <li role="presentation"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
                </ul>

                <div class="tab-content">

                <div role="tabpanel" class="tab-pane active" id="tab1">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
                <i class="fa fa-plus mright-1"></i> panel 1-1
                </a>
                </h4>
                </div>
                <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
                <div class="panel-body">
                <div class="row mtop-2">
                .... panel 1-1
                </div>
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
                <i class="fa fa-edit mright-1"></i> panel 1-2
                </a>
                </h4>
                </div>
                <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
                <div class="panel-body">
                .... panel 1-3
                </div>
                </div>
                </div>
                </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="tab2">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
                <i class="fa fa-plus mright-1"></i> panel 2-1
                </a>
                </h4>
                </div>
                <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
                <div class="panel-body">
                panel 2-1
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
                <i class="fa fa-edit mright-1"></i> panel 2-2
                </a>
                </h4>
                </div>
                <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
                <div class="panel-body">
                panel 2-2

                </div>
                </div>
                </div>
                </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="tab3">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
                <i class="fa fa-plus mright-1"></i> panel 3-1
                </a>
                </h4>
                </div>
                <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
                <div class="panel-body">
                panel 3-1
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
                <i class="fa fa-edit mright-1"></i> panel 3-2
                </a>
                </h4>
                </div>
                <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
                <div class="panel-body">
                panel 3-2
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>





                $(document).ready(function(){

                $('#mytabs a[href="#tab3"]').tab('show')

                });

                <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
                <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

                <div class="container">
                <div class="row mtop-2">
                <div class="col-md-12 col-xs-10">
                <ul class="nav nav-pills" role="tablist" id="mytabs">
                <li role="presentation" ><a href="#tab1" aria-controls="home" role="tab" data-toggle="tab">tab1</a></li>
                <li role="presentation"><a href="#tab2" aria-controls="home" role="tab" data-toggle="tab">tab2</a></li>
                <li role="presentation"><a href="#tab3" aria-controls="home" role="tab" data-toggle="tab">tab3</a></li>
                </ul>

                <div class="tab-content">

                <div role="tabpanel" class="tab-pane active" id="tab1">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine1" aria-expanded="true" aria-controls="collapseMachine1">
                <i class="fa fa-plus mright-1"></i> panel 1-1
                </a>
                </h4>
                </div>
                <div id="collapseMachine1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine1">
                <div class="panel-body">
                <div class="row mtop-2">
                .... panel 1-1
                </div>
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMachine2" aria-expanded="false" aria-controls="collapseMachine2">
                <i class="fa fa-edit mright-1"></i> panel 1-2
                </a>
                </h4>
                </div>
                <div id="collapseMachine2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMachine2">
                <div class="panel-body">
                .... panel 1-3
                </div>
                </div>
                </div>
                </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="tab2">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot1" aria-expanded="true" aria-controls="collapseRobot1">
                <i class="fa fa-plus mright-1"></i> panel 2-1
                </a>
                </h4>
                </div>
                <div id="collapseRobot1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot1">
                <div class="panel-body">
                panel 2-1
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseRobot2" aria-expanded="false" aria-controls="collapseRobot2">
                <i class="fa fa-edit mright-1"></i> panel 2-2
                </a>
                </h4>
                </div>
                <div id="collapseRobot2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseRobot2">
                <div class="panel-body">
                panel 2-2

                </div>
                </div>
                </div>
                </div>
                </div>

                <div role="tabpanel" class="tab-pane" id="tab3">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingOne">
                <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould1" aria-expanded="true" aria-controls="collapseMould1">
                <i class="fa fa-plus mright-1"></i> panel 3-1
                </a>
                </h4>
                </div>
                <div id="collapseMould1" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould1">
                <div class="panel-body">
                panel 3-1
                </div>
                </div>
                </div>

                <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingTwo">
                <h4 class="panel-title">
                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseMould2" aria-expanded="false" aria-controls="collapseMould2">
                <i class="fa fa-edit mright-1"></i> panel 3-2
                </a>
                </h4>
                </div>
                <div id="collapseMould2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="collapseMould2">
                <div class="panel-body">
                panel 3-2
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>
                </div>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 23 '18 at 7:09









                Sumesh TGSumesh TG

                2,1331825




                2,1331825
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441935%2fopen-a-specific-bootstrap-tab-on-page-load-using-jquery%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    RAC Tourist Trophy