-2

I am trying to make a light/dark theme of settings. but I have settings on another page so when I go to setting and pick a theme and go to homepage my theme resets to the original.

my jquery code:

$(document).ready(function(){
    $(":radio").click(function(){
        if( $("#btnradio1").is(':checked')){
       if ($("body").hasClass("ndark")) {
        $.removeCookie('theme2');   
        $("body").removeClass("ndark").addClass("nlight");
        $("nav").removeClass("navd").addClass("navl");
        $("nav").removeClass("white").addClass("pis");
        $.cookie('theme1', $('btnradio1'));
        $.cookie('theme1');
        console.log($.cookie('theme1'));
       }
    } else {
        $.removeCookie('tema1');
    
        $("body").removeClass("nlight").addClass("ndark");
        $("nav").removeClass("navl").addClass("navd");
        $.cookie('theme2', $('btnradio2'));
        $.cookie('theme2');
        console.log($.cookie('theme2'));
    }
        });
    });

and here are some imagese for better understanding:

before setting light mode

,

setting light mode

,

after setting and click home link

,

Dan
  • 2,952
  • 3
  • 18
  • 25
Rokus
  • 1
  • 1
  • Please do not use cookies. We use [localStorage now](https://stackoverflow.com/questions/68233773/how-to-save-darkmode-in-local-storage-by-jquery) – mplungjan May 28 '22 at 13:47
  • Welcome to Stack Overflow! Please visit [help], take [tour] to see what and [ask]. Do some research, [search for related topics on SO](https://www.google.com/search?q=jquery+save+light+dark+mode+site:stackoverflow.com); – mplungjan May 28 '22 at 13:48

0 Answers0