title: Storing dark mode preference for my website
body: <p>I have created dark mode for my website but when I turn dark mode on then refresh the page or navigate away the preference resets. I need a way of storing the preference as a cookie. Here is the code I have added to jquery. I also defined the dark mode colours in my css files.</p>
  
  <pre><code>    $( ".inner-switch" ).on("click", function() {
      if( $( "body" ).hasClass( "dark" )) {
    $( "body" ).removeClass( "dark" );
    $( "nav" ).removeClass( "navbar navbar-expand-md navbar-dark" );
    $( "nav" ).addClass( "navbar navbar-expand-md navbar-light");
    $( ".inner-switch" ).text( "OFF" );
    } else {
    $( "body" ).addClass( "dark" );
    $( "nav" ).addClass( "navbar navbar-expand-md navbar-dark");
    $( ".inner-switch" ).text( "ON" );
    }
  });
  </code></pre>