That helped - you are the best, thank you!
A small "problem" though (of which I think, I understand the logic of the code and perhaps, this could not be solved with the way the toggle function is set up on the site). What happens now is that as soon as one toggles the mode from normal to dark, it stays in the dark mode. I mean, one can toggle back to the normal mode, yes - but when refreshing the page or moving on to another page, it loads in the dark mode again.
Since this is local storage, the above happens even after closing and re-opening the browser (and thereby cleaning out all the cookies, storage and stuff). So, I switched to session storage instead. This way, a returning visitor / new browser session gets the site shown in normal mode initially and has one shot only to toggle the mode for the remaining browser session.
Sorry, for the English as I'm not a native speaker but I hope, you know what I mean. I ended up with this code and this is by far sufficient for my needs - so thank you once again for your help:
// toggle mode if button is clicked
$('.change-mode-button').click(function() {
changeMode();
});
function changeMode() {
var element = document.body;
element.classList.toggle("dark-mode");
sessionStorage.setItem("changeMode", element.classList.contains("dark-mode"));
}
var element = document.body;
if(sessionStorage.getItem("changeMode")) {
element.classList.add("dark-mode");
}
Cheers, Eric
P.S. As I am new to this forum... is there a possibilty (or is it expected at all) to mark this topic as solved - and perhaps rate your help?