title: Light mode dark mode toggle
body: <p>Im trying to make a theme toggle button for my web page. I'm starting just trying to make the SVGs toggle based on whether your currently on dark mode or light mode. I have tested and the buttons work fine when transferring from one to the other. However when I then try and toggle back it doesnt work, could someone offer a solution please.</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>function ToggleTheme() {
      var themeToggleDark = document.getElementsByClassName("theme-toggle-dark")[0];
      var themeToggleLight = document.getElementsByClassName("theme-toggle-light")[0];
  
      if (themeToggleLight.style.visibility = "hidden") {
          themeToggleDark.style.visibility = "visible";
      }
  
      else {
          themeToggleDark.style.visibility = "hidden";
      }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;svg width="100px" class="theme-toggle-dark" alt="Icon used for changing site theme to dark" onclick="ToggleTheme()" aria-hidden="true" focusable="false" data-prefix="far" data-icon="moon" class="svg-inline--fa fa-moon fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"&gt;&lt;path fill="currentColor" d="M279.135 512c78.756 0 150.982-35.804 198.844-94.775 28.27-34.831-2.558-85.722-46.249-77.401-82.348 15.683-158.272-47.268-158.272-130.792 0-48.424 26.06-92.292 67.434-115.836 38.745-22.05 28.999-80.788-15.022-88.919A257.936 257.936 0 0 0 279.135 0c-141.36 0-256 114.575-256 256 0 141.36 114.576 256 256 256zm0-464c12.985 0 25.689 1.201 38.016 3.478-54.76 31.163-91.693 90.042-91.693 157.554 0 113.848 103.641 199.2 215.252 177.944C402.574 433.964 344.366 464 279.135 464c-114.875 0-208-93.125-208-208s93.125-208 208-208z"&gt;&lt;/path&gt;&lt;/svg&gt;
  &lt;svg width="100px" class="theme-toggle-light" alt="Icon used for changing site theme to light" onclick="ToggleTheme()" aria-hidden="true" focusable="false" data-prefix="far" data-icon="sun" class="svg-inline--fa fa-sun fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"&gt;&lt;path fill="currentColor" d="M494.2 221.9l-59.8-40.5 13.7-71c2.6-13.2-1.6-26.8-11.1-36.4-9.6-9.5-23.2-13.7-36.2-11.1l-70.9 13.7-40.4-59.9c-15.1-22.3-51.9-22.3-67 0l-40.4 59.9-70.8-13.7C98 60.4 84.5 64.5 75 74.1c-9.5 9.6-13.7 23.1-11.1 36.3l13.7 71-59.8 40.5C6.6 229.5 0 242 0 255.5s6.7 26 17.8 33.5l59.8 40.5-13.7 71c-2.6 13.2 1.6 26.8 11.1 36.3 9.5 9.5 22.9 13.7 36.3 11.1l70.8-13.7 40.4 59.9C230 505.3 242.6 512 256 512s26-6.7 33.5-17.8l40.4-59.9 70.9 13.7c13.4 2.7 26.8-1.6 36.3-11.1 9.5-9.5 13.6-23.1 11.1-36.3l-13.7-71 59.8-40.5c11.1-7.5 17.8-20.1 17.8-33.5-.1-13.6-6.7-26.1-17.9-33.7zm-112.9 85.6l17.6 91.2-91-17.6L256 458l-51.9-77-90.9 17.6 17.6-91.2-76.8-52 76.8-52-17.6-91.2 91 17.6L256 53l51.9 76.9 91-17.6-17.6 91.1 76.8 52-76.8 52.1zM256 152c-57.3 0-104 46.7-104 104s46.7 104 104 104 104-46.7 104-104-46.7-104-104-104zm0 160c-30.9 0-56-25.1-56-56s25.1-56 56-56 56 25.1 56 56-25.1 56-56 56z"&gt;&lt;/path&gt;&lt;/svg&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>Images</p>
  <p>Before onClick</p>
  <p><a href="https://i.stack.imgur.com/v3FzL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v3FzL.png" alt="enter image description here" /></a></p>
  <p>After onClick</p>
  <p><a href="https://i.stack.imgur.com/YtAuE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YtAuE.png" alt="enter image description here" /></a></p>
  <p>Im trying to get from the moon icon back to the sun icon after ive clicked im summary.</p>