0

How can i switch tabs with the links?

This is my current state

<div class="tabbable-panel">
  <div class="tabbable-line">
    <ul class="nav nav-tabs">
      <li class="active">
        <a href="#tab_below_1" data-toggle="tab">Home</a>
      </li>
      <li class="">
        <a href="#tab_below_2" data-toggle="tab">Sources</a>
      </li>
      <li>
        <a href="#tab_below_3" data-toggle="tab">Contact Us</a>
      </li>
    </ul>
  </div>
</div>

I can switch between tabs just fine but when i try to make it so that the href lead to another link, it doesn't work. when i change

<a href="#tab_below_1" data-toggle="tab">Home</a>

to

<a href="mysite.com/home" data-toggle="tab">Home</a>

it doesn't work. but then i tried removing the data-toggle and it opens the link but it doesn't show that the tab is active.

Nhan
  • 3,595
  • 6
  • 30
  • 38
Dark Sterix
  • 99
  • 1
  • 3
  • 9
  • I could you replicate your issue , by removing the bootstrap.min.js file -http://codepen.io/nagasai/pen/JKEYod – Naga Sai A Jun 24 '16 at 01:56
  • Can you try adding onclick event -onclick="location.href='mysite.com/home'" in anchor tag? – Naga Sai A Jun 24 '16 at 03:27
  • Possible duplicate of [Linking to a Bootstrap Tab from outside - how to set the tab to "active"?](http://stackoverflow.com/questions/19814481/linking-to-a-bootstrap-tab-from-outside-how-to-set-the-tab-to-active) – Gleb Kemarsky Jun 24 '16 at 07:03

3 Answers3

0

Remove the data-toggle and replace it with class="active"

<div class="tabbable-panel">
    <div class="tabbable-line">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#tab_below_1">Home</a></li>
            <li><a href="#tab_below_2">Sources</a></li>
            <li><a href="#tab_below_3">Contact Us</a></li>
        </ul>
    </div>
</div>
Michelle Ashwini
  • 910
  • 2
  • 13
  • 28
  • It goes to the page but it doesn't make the tab active. when the `
  • ` is active, it's suppose to change background, but it doesn't when i replace it with `class="active"`
  • – Dark Sterix Jun 24 '16 at 01:43