So I successfully implemented a dark mode on the front page using the following script (sourced from W3schools) :
<script>
function darklightmode() {
var element = document.body;
element.classList.toggle("dmode");
} </script>
Here's the button code:
<button onclick="darklightmode()" style="background:none; border: none;">
<img src="images/ld-icon.png" class="icon">
</button>
I also added some CSS for an example:
.dmode li a{
transition: 1s all;
color: #2E3440;
background: none;}
Now my question is, how can I ensure that the selected mode (light or dark) remains consistent across multiple pages without reverting back to default when navigating to another page? Any Javascript suggestions would be greatly appreciated. Thanks!