mirror of
https://github.com/kognise/water.css.git
synced 2025-08-18 19:02:05 +02:00
Add theme switcher
This commit is contained in:
11
docs/script.js
Normal file
11
docs/script.js
Normal file
@@ -0,0 +1,11 @@
|
||||
document.getElementById('switch').addEventListener('click', () => {
|
||||
const { body } = document
|
||||
const ph = document.getElementById('ph')
|
||||
if (body.className) {
|
||||
body.className = ''
|
||||
ph.src = ph.src.replace('theme=light', 'theme=dark')
|
||||
} else {
|
||||
body.className = 'light'
|
||||
ph.src = ph.src.replace('theme=dark', 'theme=light')
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user