title: Info with checkbox 'checked' property to be saved in local storage
body: <p>I would like to save the 'checked' property of a certain checkbox to the local storage, when I refresh the page, the property is lost and the check box is unchecked.
  What could I change to make this work? I am stuck on this problem for a bit of time.
  The first part is the JS, and the second part is only the part where i define the checkbox in the HTML.
  Here is my code:</p>
  <pre><code>&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;script&gt;
   
      function myFunction() {
          var isChecked = document.getElementById(&quot;chk&quot;).checked;
          if (isChecked) {
              //header start
              document.getElementById(&quot;logo&quot;).innerHTML = &quot;ZMP Polyhymnia&quot;;
              document.getElementById(&quot;dash&quot;).innerHTML = &quot;Dashboard&quot;;
              document.getElementById(&quot;festival&quot;).innerHTML = &quot;Festival&quot;;
              document.getElementById(&quot;contest&quot;).innerHTML = &quot;Contest&quot;;
              document.getElementById(&quot;jury&quot;).innerHTML = &quot;Jury&quot;;
              document.getElementById(&quot;res&quot;).innerHTML = &quot;Results&quot;;
              document.getElementById(&quot;contacUs&quot;).innerHTML = &quot;Contact&quot;;
              //header end
              //hero start
              document.getElementById(&quot;heading2&quot;).innerText = &quot;V International Festival Polyhymnia 2020 Skopje&quot;;
              document.getElementById(&quot;firstPar&quot;).innerText = &quot;International competition Polyhymnia: &quot;;
              document.getElementById(&quot;secondPar&quot;).innerText = &quot;-Concerts, Music workshops and Seminars&quot;;
              document.getElementById(&quot;thirdPar&quot;).innerText = &quot;-Announcing Laureate of the competition and many other awards from the competition prize fond&quot;
              document.getElementById(&quot;fourthPar&quot;).style.visibility = &quot;hidden&quot;;
              //hero end
              //festival start
              document.getElementById(&quot;festivalH&quot;).innerHTML = &quot;Festival&quot;;
              document.getElementById(&quot;festivalPar&quot;).innerText = &quot;    International Festival Polyhymnia is a manifestation that is traditionally held for the third consecutive year in the second half of March through the concert halls around the capital. Participants are learners and students from the Republic of Macedonia, neighboring countries and participants from European countries. This year the festival will be held in Skopje from 28.03.2018 until 01.04.2018. This year will be represented several categories ofinstruments for solo and chamber performance (piano, flute, violin, cello, trumpet, clarinet, solo singing).&quot;
              //festival end
  
          }
          else {
              //header start
              document.getElementById(&quot;logo&quot;).innerHTML = &quot;ЗМП Полихимнија&quot;;
              document.getElementById(&quot;dash&quot;).innerHTML = &quot;Почетна&quot;;
              document.getElementById(&quot;festival&quot;).innerHTML = &quot;Фестивал&quot;;
              document.getElementById(&quot;contest&quot;).innerHTML = &quot;Натпревар&quot;;
              document.getElementById(&quot;jury&quot;).innerHTML = &quot;Жири&quot;;
              document.getElementById(&quot;res&quot;).innerHTML = &quot;Резултати&quot;;
              document.getElementById(&quot;contacUs&quot;).innerHTML = &quot;Контакт&quot;;
              //header end
              //hero start
              document.getElementById(&quot;heading2&quot;).innerText = &quot;Петти меѓународен фестивал Полихимниа 2020 Скопје&quot;;
              document.getElementById(&quot;firstPar&quot;).innerText = &quot;Во рамките на фестивалот ќе се одржи:&quot;;
              document.getElementById(&quot;secondPar&quot;).innerText = &quot; -Меѓународен Натпревар Полихимниа 2020&quot;;
              document.getElementById(&quot;thirdPar&quot;).innerText = &quot;-Концерт, работилници и семинари за ученици и студенти&quot;
              document.getElementById(&quot;fourthPar&quot;).style.visibility = &quot;visible&quot;;
              //hero end
              //festival start
              document.getElementById(&quot;festivalH&quot;).innerHTML = &quot;Фестивал&quot;;
              document.getElementById(&quot;festivalPar&quot;).innerText = &quot;     Меѓународниот фестивал на Полихимниа е манифестација која традиционално се одржува трета година по ред во втората половина од месец март низ концертните сали ширум главниот град. Учество земаат ученици и студенти од Република Македонија, соседните земји, но и учесници од Европските земји. Оваа година фестивалот ќе се одржи во Скопје од 28.03.2018 до 01.04.2018 година. Oваа година  ќе бидат застапени повеќе категории на инструменти за соло и камерна изведба  ( пијано, флејта, виолина,виолончело, труба, кларинет, соло пеење ).&quot;
              //festival end
  
          }
      }
  
      $('#chk').click(function (e) {
          if (e.target.checked) {
              localStorage.checked = true;
          } else {
              localStorage.checked = false;
          }
      })
  
      $(document).ready(function () {
  
          document.querySelector('#chk').checked = localStorage.checked
  
      });
  &lt;/script&gt;
  </code></pre>
  <p>//this is the HTML PART</p>
  <pre><code>   &lt;label class=&quot;switch&quot;&gt;
       &lt;input type=&quot;checkbox&quot; id=&quot;chk&quot; onclick=&quot;myFunction()&quot;&gt;
              &lt;span class=&quot;slider round&quot;&gt;&lt;/span&gt;
      &lt;/label&gt;
  </code></pre>