MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / switchTheme

Function switchTheme

assets/js/script.js:3–10  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

1const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
2
3function switchTheme(e) {
4 if (e.target.checked) {
5 document.documentElement.setAttribute('data-theme', 'dark');
6 }
7 else {
8 document.documentElement.setAttribute('data-theme', 'light');
9 }
10}
11
12toggleSwitch.addEventListener('change', switchTheme, false);
13

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected