mirror of
https://github.com/kognise/water.css.git
synced 2025-07-31 10:20:31 +02:00
Update theme switching code
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
document.getElementById('switch').addEventListener('click', () => {
|
||||
const { body } = document
|
||||
const ph = document.getElementById('ph')
|
||||
if (body.className) {
|
||||
body.className = ''
|
||||
if (body.classList.contains('light')) {
|
||||
body.classList.remove('light')
|
||||
ph.src = ph.src.replace('theme=light', 'theme=dark')
|
||||
} else {
|
||||
body.className = 'light'
|
||||
body.classList.add('light')
|
||||
ph.src = ph.src.replace('theme=dark', 'theme=light')
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user