title: Form submit should stay on the same tab
body: <p>On submitting the form by clicking a button, upon page reload same tab should be opened, but it is going to default tab. I have tried <strong>local storage</strong> but it doesn't work. What is wrong with my code?</p>
  
  <p>[This is working now. See my answer below]</p>
  
  <p>jQuery:</p>
  
  <pre><code>$(document).ready(function() {
            $('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
             localStorage.setItem('activeTab', $(e.target).attr('href'));
             });
             var activeTab = localStorage.getItem('activeTab');
             if(activeTab){
             $('#myTab a[href="' + activeTab + '"]').tab('show');
             }
  $('.tabs .tab-links a').on('click', function(e)  {
              var currentAttrValue = jQuery(this).attr('href');
              // Show/Hide Tabs
              jQuery('.tabs ' + currentAttrValue).siblings().slideUp(400);
              jQuery('.tabs ' + currentAttrValue).delay(400).slideDown(400);
              // Change/remove current tab to active
              jQuery(this).parent('li').addClass('active').siblings().removeClass('active');       
              e.preventDefault();
              });
  $('#btnLock').click(function() {
              $('#lockForm').submit();
              });
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div class="tabs" align="center"&gt;
    &lt;ul class="tab-links"&gt;
      &lt;li class="active"&gt;&lt;a data-toggle="tab" href="#tabs-1"&gt;Register&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a data-toggle="tab" href="#tabs-2"&gt;Lock&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;div class="tab-content"&gt;
      &lt;div id="tabs-1" class="tab active"&gt;
          &lt;form:form....&gt; &lt;div class="plinput"&gt;&lt;a id="btnRegister" class="abutton"&gt;Register&lt;/a&gt;&lt;/div&gt; 
          &lt;/form:form&gt;
      &lt;/div&gt;
      &lt;div id="tabs-2" class="tab"&gt;
          &lt;form:form...&gt; &lt;div class="plinput"&gt;&lt;a id="btnLock" class="abutton"&gt;Lock&lt;/a&gt;&lt;/div&gt;
          &lt;/form:form&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>