title: Can I toggle dark mode using JavaScript?
body: <p>I am using <code>prefers-color-scheme: dark</code> to create a dark theme in CSS (it applies to Safari in <a href="https://en.wikipedia.org/wiki/MacOS_Mojave" rel="noreferrer">macOS v10.14</a> (Mojave)). Is there a way to force the page to use my dark mode code on other browsers that don't support it, like the following?</p>
  
  <pre><code>document.querySelector('#toggleDarkMode').addEventListener('click', function () {
      -- Force page to use dark mode defined in CSS
  })
  </code></pre>