title: keep the current tab active with twitter bootstrap after a page reload?
body: <p>I know this question was asked before and answered in the following post:</p>
  
  <p><a href="https://stackoverflow.com/questions/10523433/how-do-i-keep-the-current-tab-active-with-twitter-bootstrap-after-a-page-reload/10524697#10524697">How do I keep the current tab active with twitter bootstrap after a page reload?</a></p>
  
  <p>However, given my limited knowledge of scripting, I have not been able to get this to work on my website. After putting the code in my html page the tabs still go to the first and active one on page reload.</p>
  
  <p>Please can someone share a working example of the solution presented in the link above.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>&lt;div class="tabbable" style="margin-bottom: 8px;"&gt;
          &lt;ul class="nav nav-tabs"&gt;
            &lt;li class="active"&gt;&lt;a href="#tab1" data-toggle="tab"&gt;My Career Centre&lt;/a&gt;&lt;/li&gt;
            &lt;li class=""&gt;&lt;a href="#tab2" data-toggle="tab"&gt;Hiring Companies&lt;/a&gt;&lt;/li&gt;
            &lt;li class=""&gt;&lt;a href="#tab3" data-toggle="tab"&gt;Training Providers&lt;/a&gt;&lt;/li&gt;
            &lt;li class=""&gt;&lt;a href="#tab4" data-toggle="tab"&gt;Advertise&lt;/a&gt;&lt;/li&gt;
            &lt;li class=""&gt;&lt;a href="#tab5" data-toggle="tab"&gt;Graduate Opportunities&lt;/a&gt;&lt;/li&gt;
            &lt;li class=""&gt;&lt;a href="#tab6" data-toggle="tab"&gt;Career Forum&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;           
          &lt;script type="text/javascript"&gt;
                    $(function() 
                      { 
                        $('a[data-toggle="tab"]').on('shown', function (e) {
                          //save the latest tab; use cookies if you like 'em better:
                          localStorage.setItem('lastTab', $(e.target).attr('id'));
                        });
  
                        //go to the latest tab, if it exists:
                        var lastTab = localStorage.getItem('lastTab');
                        if (lastTab) {
                            $('#'+lastTab).tab('show');
                        }
                      });
              &lt;/script&gt;
  
          &lt;div class="tab-content" style="padding: 0 5px;"&gt;
             &lt;div class="tab-pane active" id="tab1"&gt;
                  &lt;div class="navbar" style="width:930px;"&gt;
                    &lt;div class="navbar-inner"&gt;
                      &lt;div class="container"&gt;
                        &lt;ul class="nav2" style="padding-top:0px;"&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Job Search&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Training Programmes&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Job Alerts&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;My Job Applications&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;My Studies&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="http://localhost:8080/nationalcareers/JOBSEEKERS/index.php?category=home&amp;action=received"&gt;Received Messages&lt;/a&gt;&lt;/li&gt;
                        &lt;/ul&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
             &lt;/div&gt;
             &lt;div class="tab-pane" id="tab2"&gt;
              &lt;div class="navbar" style="width:900px;"&gt;
                    &lt;div class="navbar-inner"&gt;
                      &lt;div class="container"&gt;
                        &lt;ul class="nav2" style="padding-top:0px;"&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Manage Your Job Adverts&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Browse CV's&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Manage Job Applications&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="http://localhost:8080/nationalcareers/EMPLOYERS/index.php?category=postings&amp;action=my"&gt;View Reports For Your Adverts&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="http://localhost:8080/nationalcareers/EMPLOYERS/index.php?category=home&amp;action=sub_accounts"&gt;Manage Sub-Accounts&lt;/a&gt;&lt;/li&gt;
                        &lt;/ul&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="tab-pane" id="tab3"&gt;
              &lt;div class="navbar" style="width:900px;"&gt;
                    &lt;div class="navbar-inner"&gt;
                      &lt;div class="container"&gt;
                        &lt;ul class="nav2" style="padding-top:0px;"&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Browse Training Programmes&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Browse Featured Training Providers&lt;/a&gt;&lt;/li&gt;
                        &lt;/ul&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
             &lt;/div&gt;
             &lt;div class="tab-pane" id="tab4"&gt;
              &lt;div class="navbar" style="width:900px;"&gt;
                    &lt;div class="navbar-inner"&gt;
                      &lt;div class="container"&gt;
                        &lt;ul class="nav2" style="padding-top:0px;"&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Jobs&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Training Programmes&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Your Company&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Your Recruitment Agency&lt;/a&gt;&lt;/li&gt;
                        &lt;/ul&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
             &lt;/div&gt;
             &lt;div class="tab-pane" id="tab5"&gt;
              &lt;div class="navbar" style="width:900px;"&gt;
                    &lt;div class="navbar-inner"&gt;
                      &lt;div class="container"&gt;
                        &lt;ul class="nav2" style="padding-top:0px;"&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Search Current Opportunities&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;News and Updates&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Events&lt;/a&gt;&lt;/li&gt;
                        &lt;/ul&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="tab-pane" id="tab6"&gt;
              &lt;div class="navbar" style="width:900px;"&gt;
                    &lt;div class="navbar-inner"&gt;
                      &lt;div class="container"&gt;
                        &lt;ul class="nav2" style="padding-top:0px;"&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Career Advice&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;CV/Resume&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Interview Preparation&lt;/a&gt;&lt;/li&gt;
                          &lt;li&gt;&lt;a href="#"&gt;Career Net-Work&lt;/a&gt;&lt;/li&gt;
                        &lt;/ul&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
             &lt;/div&gt;
          &lt;/div&gt;
          &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Highly appreciated,</p>