Precise Dentistry
Learned together
function toggleNightMode() {
const body = document.body;
const isNight = body.classList.toggle('night-mode');
localStorage.setItem('nightMode', isNight);
updateButton(isNight);
}
function updateButton(isNight) {
const btn = document.getElementById('nightModeToggle');
btn.innerHTML = isNight ? '☀️ Day Mode' : '🌙 Night Mode';
}
window.addEventListener('DOMContentLoaded', function() {
if (localStorage.getItem('nightMode') === 'true') {
document.body.classList.add('night-mode');
updateButton(true);
}
});
body.night-mode,
body.night-mode html,
body.night-mode #page,
body.night-mode .site,
body.night-mode header,
body.night-mode .site-header,
body.night-mode #masthead,
body.night-mode .header-inner,
body.night-mode .site-branding {
background-color: #000 !important;
color: #fff !important;
}
body.night-mode h1,
body.night-mode h2,
body.night-mode h3,
body.night-mode p,
body.night-mode a {
color: #fff !important;
}
#nightModeToggle:hover {
background-color: rgba(255,255,255,0.1) !important;
}
Learned together