2

I have 2 css files for light mode & dark mode of the website
light.css & dark.css in the same directory.

<nav class="nav-menu">
      <ul>
        <li class="active"><a href="#intro"><i class="bx bx-home"></i> <span>Home</span></a></li>
        <li><a href="#button"><i class="bx bx-button"></i> <span>Toggle</span></a></li>
      </ul>
    </nav>

I have already integrated the light mode css file in the HTML. How can I use the

<li><a href="#button"><i class="bx bx-button"></i> <span>Toggle</span></a></li>

toggle icon to switch to dark mode css file in my website ?

V_ Srj
  • 15
  • 1
  • 6
  • https://stackoverflow.com/questions/2685614/load-external-css-file-like-scripts-in-jquery-which-is-compatible-in-ie-also/2685661#:~:text=69-,Load%20external%20css%20file%20like%20scripts%20in,is%20compatible%20in%20ie%20also&text=%24(%22,appendTo(%22head%22)%3B – s.kuznetsov Aug 23 '20 at 16:32
  • switch on what?click event? – ino Aug 23 '20 at 16:32
  • or this will help you - https://stackoverflow.com/questions/5680657/adding-css-file-with-jquery/5680757 – s.kuznetsov Aug 23 '20 at 16:40
  • @Tawsif I want to toggle between my lightmode & darkmode for my website when I click using the toggle icon. I have created separate css files for both modes. Now I want to just click on the toggle icon so that my website becomes dark mode. – V_ Srj Aug 24 '20 at 10:32
  • @sergeykuznetsov I want to toggle between my lightmode & darkmode for my website when I click using the toggle icon. I have created separate css files for both modes. Now I want to just click on the toggle icon so that my website becomes dark mode. I feel the following does not align well with my doubt . – V_ Srj Aug 24 '20 at 10:33

1 Answers1

0

Add a specific id for the css link and change the value of the attribute href when trigger your selected button using javascript/jQuery.

John
  • 73
  • 8