Dark mode toggle not work in mobile

i got some code from the internet
It work well in Desktop & tablet , but the toggle seems not working in mobile . (sun switch to moon)
Do anyone can help with this problem

Here is the code :

"
function setThemeFromCookie() {
const themeState = document.getElementById(‘content’);
themeState.className = isThemeSelected() ? ‘dark-mode’ : ‘light-mode’;
}
function setThemeSwitchState() {
document.getElementById(‘toggleTheme’).checked = isThemeSelected();
}
function isThemeSelected() {
return document.cookie.match(/theme=dark/i) != null;
}
function toggleTheme() {
const themeState = document.getElementById(‘content’);
const currentState = themeState.className;
const newState = themeState.className == ‘dark-mode’ ? ‘light-mode’ : ‘dark-mode’;
themeState.className = newState;
document.cookie = ‘theme=’ + (newState == ‘light-mode’ ? ‘light’ : ‘dark’);
}
(function() {
setThemeFromCookie();
setThemeSwitchState();
document.getElementById(‘toggleTheme’).onchange=toggleTheme;
})();
"

hi @Nikki_Kang I don’t know where you have got this code but I have strong doubt that works as your text elements are wrapper in citation quote that is not recognised (accepted) in code. So you should fix this first by replacing all with single or double quotes.

Secondly it is a good practice to provide read-only link and if possible also link to published page.