Cambia tema js

Is there a script so user can change Theme ligt/dark by clicking on it,
im using the alien-night-discourse theme and they have the option to click on the sun or moon to change it but it doesnt change the theme only the background, here is the JS

<script async>
$(document).ready(function() {
	var darkTheme = localStorage.getItem("theme");
	if (darkTheme !== null){
		$('html').addClass('dark');
	}
	if (typeof(Storage) !== "undefined") {
		// Code for localStorage/sessionStorage.
		$('.theme-switcher-dark').on('click', function() {
			localStorage.setItem("theme", "dark");
			$('html').addClass('dark');
		});
		$('.theme-switcher-light').on('click', function() {
			localStorage.removeItem("theme");
			$('html').removeClass('dark');
		});
	} else {
		// Sorry! No Web Storage support..
		console.log('Upgrade to a better browser! Really!')
	}
});

Non hai avuto fortuna con la guida sui temi qui? Dovresti considerare di pubblicare lì per attirare l’attenzione di chi è già coinvolto in quell’argomento (e, in ogni caso, è anche più corretto dal punto di vista dell’etichetta del forum).

2 Mi Piace

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.