title: localStorage on .hide .show elements
body: <p>I have a web app that when a button clicks submit it loads ldap groups through JavaScript. From there, when a user clicks the group it loads the users. I have this laid out on a single HTML page with other divs acting as separate pages, such as password reset and account locking. To hide/show the divs from the nav:</p>
  
  <pre><code>$(document).on('click', '#navMenu li a', 
  function(nav) {
      $('.navlinks').hide();
      $(this.getAttribute('data-tab')).show()
  })
  </code></pre>
  
  <p>My issue right now is that once a user is added to a group via a modal form, on submit the form refreshes the page and send the user back to the first tab and shows the first div, instead of keeping the active div open. </p>
  
  <p>I've written this <code>localStorage</code> snipped to try to use that route, but it's still refreshing back. Any ideas or hints?</p>
  
  <pre><code>$(document).ready(function() {
      var last_id = localStorage.getItem('tab_id');
      if(last_id) {
          $('ul.navbar-menu li a').removeClass('active');
          $('.navLinks').removeClass('active');
          $('.navbar-menu li a').eq(Number(last_id.match(/\d+/)[0])-1).addClass('active');
          $('#' + last_id).addClass('active');
      }
      $('ul.navbar-menu li a').click(function() {
          var tab_id = $(this).attr('data-tab');
          $('ul.navbar-menu li a').removeClass('active');
          $('.navLinks').removeClass('active');
          $(this).addClass('active');
          $('#' + tab_id).addClass('active');
          localStorage.setItem('tab_id', tab_id);
      });
  })
  </code></pre>