diff --git a/function.js b/function.js index 0fd4f43..ef4c6fd 100644 --- a/function.js +++ b/function.js @@ -15,4 +15,21 @@ var checkbox = document.querySelector('input[name=mode]'); window.setTimeout(() => { document.documentElement.classList.remove('transition'); }, 1000) - } \ No newline at end of file + } + + 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); + }); \ No newline at end of file diff --git a/index.html b/index.html index ca865ed..822f3ca 100644 --- a/index.html +++ b/index.html @@ -49,5 +49,5 @@ - + \ No newline at end of file