title: Use localStorage.setItem to keep same show/hide divs
body: <p>I work with a function in my main page. All works fine, I just want to know how to  keep the select language in a page when i click on a link and go in another page.</p>
  
  <p>For example id="en" is the language by default, but if I want to use id="fr" in my main page, and click on link who will send me in another page. I will come back to id="en". So to keep the same language how can I use this function :</p>
  
  <pre><code>localStorage.setItem("language", selectedLanguage);
  currentlanguage= localStorage.getItem("language"); 
  </code></pre>
  
  <p>Here is the jsfiddle of the function that I use to switch language:</p>
  
  <p><a href="https://jsfiddle.net/kodjoe/chvw181j/" rel="nofollow">https://jsfiddle.net/kodjoe/chvw181j/</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $('.lan').hide();
    $('.en').show();
  });
  
  $('.button').click(function(event) {
    $('.lan').hide();
    var selectedLanguage = $(this).attr('id');
    var setActiveLanguage = "." + selectedLanguage;
    $(setActiveLanguage).show();
  
  localStorage.setItem("language", selectedLanguage);
  currentlanguage= localStorage.getItem("language"); 
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.button {
    cursor: pointer;
    padding: 0px 30px;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;a class="button" id="en"&gt;EN&lt;/a&gt;
  &lt;a class="button" id="fr"&gt;FR&lt;/a&gt;
  &lt;a class="button" id="de"&gt;DE&lt;/a&gt;
  
  
  &lt;div class="lan en"&gt;1&lt;/div&gt;
  &lt;div class="lan fr"&gt;2&lt;/div&gt;
  &lt;div class="lan de"&gt;3&lt;/div&gt;
  &lt;div class="lan en"&gt;4&lt;/div&gt;
  &lt;div class="lan fr"&gt;5&lt;/div&gt;
  &lt;div class="lan de"&gt;6&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>