title: How to check & uncheck checkbox onload function?
body: <p>I have a code in which if my checkbox is checked and if I load window(page) checkbox should remain there on reload OR if I uncheck the checkbox and reload page then checkbox should remain unchecked. my code is as following.</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-html lang-html prettyprint-override"><code>&lt;input type="checkbox" id="chk"&gt;
  &lt;script&gt;
      window.onload = onPageLoad();
      function onPageLoad() {
          if (document.getElementById("chk").checked == true) {
              document.getElementById("chk").checked = true;
          } else {
              document.getElementById("chk").checked = false;
      }
      }
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>However above code returns unchecked checkbox even after reloading page after checking checkbox.</p>