'Keep dark or light mode over different pages with javascript
Basically, I got a dark mode on the front page, with the script being (from W3schools) :
<script>
function darklightmode() {
var element = document.body;
element.classList.toggle("dmode");
} </script>
And the button :
<button onclick="darklightmode()" style="background:none; border: none;">
<img src="images/ld-icon.png" class="icon">
</button>
and some CSS just for example :
.dmode li a{
transition: 1s all;
color: #2E3440;
background: none;}
So how can I, with some Javascript, make the mode the user is using stay between pages and not come back to default when accessing another page ?
Beginner here, any help appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
