title: Change bootstrap 4 collaplse state with localStorage
body: <p>So I have a localStorage which is true of false, and if it's true the <code>collaplse</code> should be shown, and if flase <code>hidden</code> on page load. But how can I change the state automatic, if the localStorage is either true/false?</p>
  <p>My localStorage is</p>
  <pre class="lang-js prettyprint-override"><code>function showTable(display) {
      if (display) {
          localStorage.setItem(&quot;dashboardViewTable&quot;, display);
      } else {
          localStorage.setItem(&quot;dashboardViewTable&quot;, display);
      }
  }
  </code></pre>
  <p>I tried to see if the class just could be removed/added but that doesn't work?</p>
  <pre class="lang-js prettyprint-override"><code>function getTableState() {
      var element = document.getElementById(&quot;dashboardViewTable&quot;);
      if (localStorage.getItem(&quot;dashboardViewTable&quot;)) {
          element.classList.add(&quot;show&quot;);
      } else {
          element.classList.remove(&quot;show&quot;);
      }
  }
  </code></pre>
  <p>How do I change the toggling of a bootstrap collaplse, with js?</p>