-1

Hi i want to change the active tab with jquery this is my code

so what is the solution please

<nav class="navbar navbar-inverse" role="navigation">
  <div class="container">

    <div class="navbar-header">

      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#top-navbar-1">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
      <a class="navbar-brand visible-xs" href="index.html">Titel</a>
    </div>
    <div class="collapse navbar-collapse" id="top-navbar-1">
      <ul id="collapsablenav" class="nav navbar-nav navbar-right">
        <li class="active dropdown hidden-xs">
          <a data-toggle="dropdown" href="#" class="dropdown-toggle"> <b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li id="CDCDC">
              <a data-toggle="tab" href="#ABAB"></a>
            </li>
            <li class="divider"></li>
            <li class="active" id="testclocalisation"><a data-toggle="tab" href="#hometab">AZ</a></li>
          </ul>
        </li>
        <li class="active visible-xs"><a data-toggle="tab" href="#FFFF">F</a></li>
        <li id="testFFFFFF"><a data-toggle="tab" href="#DDDDD">D</a></li>
        <li id="testCCCCCC"><a data-toggle="tab" href="#CCCCCC">C</a></li>
        <li id="testBBBBB"><a data-toggle="tab" href="#BBBBB">B</a></li>
        <li id="testAAAAAA"><a data-toggle="tab" href="#AAAAA">A</a></li>
      </ul>
    </div>
  </div>

</nav>

so what is the solution please

Ankit Agarwal
  • 30,378
  • 5
  • 37
  • 62
Mapp
  • 1
  • 2
  • Given the bootstrap classes you've used, you probably just need to include bootstrap.js – freedomn-m Aug 09 '18 at 14:38
  • And since it is bootstrap the documentation tells you how to change tabs programmatically. What have you tried that isn't working? – charlietfl Aug 09 '18 at 14:43
  • thats what you need is: [How to trigger('click') on jquery tab's currently active tab](https://stackoverflow.com/questions/10735423/how-to-triggerclick-on-jquery-tabs-currently-active-tab) – Ahsan Haroon Aug 09 '18 at 14:52

1 Answers1

1

function changeTab( newID ) { $('.navbar li').removeClass('active'); $('#' + newID ).addClass('active'); }

Now call this function on some event and pass the Id of the li you want to make active.

Simranjit Singh
  • 384
  • 1
  • 6