mirror of
https://github.com/kognise/water.css.git
synced 2026-01-21 20:45:52 +01:00
Add theme switcher
This commit is contained in:
parent
22cae7e386
commit
aabd59c3ea
3 changed files with 17 additions and 6 deletions
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')
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue