Technically I fixed the dark mode
This commit is contained in:
parent
1ec588f814
commit
142e26d8ed
19
function.js
19
function.js
|
@ -15,4 +15,21 @@ var checkbox = document.querySelector('input[name=mode]');
|
|||
window.setTimeout(() => {
|
||||
document.documentElement.classList.remove('transition');
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
const btn = document.querySelector(".container_toggle");
|
||||
|
||||
const currentTheme = localStorage.getItem("theme");
|
||||
if (currentTheme == "dark") {
|
||||
document.body.classList.add("dark-theme");
|
||||
}
|
||||
|
||||
btn.addEventListener("click", function () {
|
||||
document.body.classList.toggle("dark-theme");
|
||||
|
||||
let theme = "light";
|
||||
if (document.body.classList.contains("dark-theme")) {
|
||||
theme = "dark";
|
||||
}
|
||||
localStorage.setItem("theme", theme);
|
||||
});
|
|
@ -49,5 +49,5 @@
|
|||
<input class="container_toggle" type="checkbox" id="switch" name="mode">
|
||||
<label for="switch">Toggle</label>
|
||||
</div>
|
||||
<script src="https://1elci.it/function.js"></script>
|
||||
<script src="/function.js"></script>
|
||||
</body>
|
Loading…
Reference in New Issue