0
Recently I was looking at some websites and found a code "Dark Mode", but when testing it I realized that it does not work in IE 11.
In IE developer mode the error is "Syntax".
Code:
const switchTumbler = () => {
const wrapper = document.querySelector(".tumbler__wrapper");
wrapper.addEventListener("click", () => {
toggleNightMode();
});
};
switchTumbler();
const toggleNightMode = () => {
document.body.classList.toggle("body--night-mode");
document.querySelector(".tumbler").classList.toggle("tumbler--night-mode");
document.querySelectorAll(".post").forEach(post => {
post.classList.toggle("post--night-mode");
});
};
They could help me, I would like to use it in IE, but I am layman in javascript.
The
IE11
does not support the function.toggle
ofclassList
. You to use the optionadd
andremove
, only.– Valdeir Psr
There is a website that I personally find very cool to check the compatibility of browsers: https://caniuse.com/
– Daniel Mendes
@Valdeirpsr here ran the
.toggle
normal ;)– Sam
@sam vi no MDN, but I got confused. What doesn’t work is the second parameter. Thank you for the correction.
– Valdeir Psr