diff --git a/script.js b/script.js index bfa4be2..4f64f80 100644 --- a/script.js +++ b/script.js @@ -1,8 +1,4 @@ document.getElementById('switch').addEventListener('click', function() { - const stylesheet = document.getElementById('stylesheet') - if (stylesheet.getAttribute('href') === 'dist/dark.min.css') { - stylesheet.setAttribute('href', 'dist/light.min.css') - } else { - stylesheet.setAttribute('href', 'dist/dark.min.css') - } -}) \ No newline at end of file + const stylesheet = document.getElementById('stylesheet'); + stylesheet.href = stylesheet.href.replace(/dark|light/, function(replaced) { return replaced === 'dark' ? 'light' : 'dark' }); +}); \ No newline at end of file