Stay in the same tab after refreshing using bootstrap

Asked

Viewed 188 times

0

Well, I’m using bootstrap tabs, but whenever I refresh to get information on this tab, it switches to the first one, coming out of the 3 ABA, someone knows how to solve this with Botstrap ?

   <ul class="nav nav-tabs">
    <li class="active"><a data-toggle="tab" href="#aba">ABA</a></li>
    <li><a data-toggle="tab" href="#aba1">ABA 1</a></li>
    <li><a data-toggle="tab" href="#aba2">ABA 2</a></li>
   </ul>

the Divs

<div class="tab-content">
 <div id="aba" class="tab-pane fade in active">ABA</div>
 <div id="aba1" class="tab-pane fade in active">ABA 1</div>
 <div id="aba2" class="tab-pane fade in active">ABA 2</div>
</div>

I have a button in Tab 2 and when I click on it to get information, it goes back to the first one, someone has some idea of how to solve this in Bootstrap ?

  • Using any programming language? or just html and css?

  • For the development of Tabs, only bootstrap same colleague

  • I found a Script that does not change, <script> $('ul.Nav-tabs li a'). click(Function(e){ e.preventDefault(); $(this).tab('show'); window.scrollTo(0, 0); }); $('ul.Nav-tabs > li > a'). on('Shown.bs.tab', Function(e){ var id = $(e.target).attr("href").substr(1); window.location.hash = id; }); var hash = window.location.hash; $('ul.Nav-tabs li a[href="' + hash + '"]'). tab('show'); </script>

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.