mirror of
https://github.com/kognise/water.css.git
synced 2025-12-08 07:45:02 +01:00
Update theme switching code
This commit is contained in:
parent
aabd59c3ea
commit
5ae08050ad
1 changed files with 3 additions and 3 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
document.getElementById('switch').addEventListener('click', () => {
|
document.getElementById('switch').addEventListener('click', () => {
|
||||||
const { body } = document
|
const { body } = document
|
||||||
const ph = document.getElementById('ph')
|
const ph = document.getElementById('ph')
|
||||||
if (body.className) {
|
if (body.classList.contains('light')) {
|
||||||
body.className = ''
|
body.classList.remove('light')
|
||||||
ph.src = ph.src.replace('theme=light', 'theme=dark')
|
ph.src = ph.src.replace('theme=light', 'theme=dark')
|
||||||
} else {
|
} else {
|
||||||
body.className = 'light'
|
body.classList.add('light')
|
||||||
ph.src = ph.src.replace('theme=dark', 'theme=light')
|
ph.src = ph.src.replace('theme=dark', 'theme=light')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue