Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

138
Visualizações
Dark/Light mode keep between switching through navigation

so I'm having an issue with this code not keeping the color of when the person chooses to switch to lightmode then move to a different page it resets. How would I change it so it could stay the color they chose between pages.

Here is the HTML

                 <div class="switch-wrap">
                    <div id="switch" class="hover-target">
                        <div id="circle"></div>
                    </div>
                    <!--Credits to Ivan Grozdic Navigation/Dark/Light-->
                    <p><span>dark</span> - <span>light</span></p>
                </div> 

Here is the javascript/jquery

    $("#switch").on('click', function () {
        if ($("body").hasClass("light")) {
            $("body").removeClass("light");
            $("#switch").removeClass("switched");
        }
        else {
            $("body").addClass("light");
            $("#switch").addClass("switched");
        }
    });
})(jQuery);

I have tried doing a document.cookies(ifDarkmode.istrue) and keeping it but I haven not gotten it to work since I am new to coding.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda