how to add theme attribute to :root
const toggleBtn = document.querySelector("#toggle-theme");
toggleBtn.addEventListener('click', e => {
console.log("Switching theme");
if(document.documentElement.hasAttribute('theme')){
document.documentElement.removeAttribute('theme');
}
else{
document.documentElement.setAttribute('theme', 'dark');
}
});
Also in JavaScript:
- on hover display block jquery
- error build react Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///' cannot be created in a document with origin 'null' and URL
- follow and unfollow node js button
- javascript if statement
- javascript format date time
- nodejs readdir
- adding growl delete notifications in vanilla js
- document addeventlistener click
- create react app scaffolding
- set iframe height and width by js
- jquery add inline style
- jquery element width
- array from js
- javascript write to text file stack overflow
- microservices architecture node
- how to get name array value in jquery
- how remove child in jquery
- express get host url
- how to send a message discord.js
- list pci express version command line
- display none js
- lodash group by except group null items
- Schema Password Hashing COde
- class query css js all