Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!