title: How to remember the buttons click state and their functions with local storage?
body: <p>I have many buttons that change/add/remove elements. Some of the elements are dynamic e.g. clicking button <strong>one</strong> will create button <strong>two</strong> etc.</p>
  <p>I'd like to save the state of the buttons/page in local storage. If I clicked button one, and then two, the background is now red. When the visitor returns (after browser close) it will be as if they have already clicked one&gt;two and will see the red background as before.</p>
  <p>I've been reading Mozilla setItem and every post on Stackoverflow about local storage but I can't find any examples of this exact scenario.
  <a href="https://jsfiddle.net/oh9q2Lzw/1/" rel="nofollow noreferrer">https://jsfiddle.net/oh9q2Lzw/1/</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>$('.one').on('click', function() {
    $('.blue').removeClass('blue').addClass('green');
  });
  
  $('.two').on('click', function() {
    $('.green').removeClass('green').addClass('red');
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>button {
    padding: 10px 40px;
  }
  
  .blue {
    width: 200px;
    padding: 20px;
    background: blue
  }
  
  .green {
    width: 200px;
    padding: 20px;
    background: green
  }
  
  .red {
    width: 200px;
    padding: 20px;
    background: red
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"&gt;&lt;/script&gt;
  
  &lt;br&gt;
  &lt;div class="box"&gt;
    &lt;button class="one"&gt;one&lt;/button&gt;
    &lt;button class="one"&gt;one&lt;/button&gt;
    &lt;button class="two"&gt;two&lt;/button&gt;
  &lt;/div&gt;
  &lt;br&gt;
  &lt;div class="blue"&gt;&lt;/div&gt;
  &lt;br&gt;
  &lt;div class="blue"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>