-1
I am trying to make a checkbox that, while activated, it activates a < class >, and when deactivated it returned to normal.
Talking about what I’m trying to do, is a button that activates a light-Theme on the site, the body is in the dark-Theme class.
The problem is that I do not know javascript yet, when I try to enable the class "light-Theme" by the javascript code does not work, if you can help thank.
Javascript
const themeSwitch = document.querySelector("input");
themeSwitch.addEventListener("change", () =>{
document.body.classList.toggle("light-theme");
});
In HTML
<label class="switch">
<i class="fas fa-adjust"></i>
<div>
<input type="checkbox" ontoggle="change"/>
<span class="slider round"></span>
</div>
</label>
I picked up the javascript code on a website (I didn’t make the code).