Use a bunch of document.querySelectors if you want to convert to raw JavaScript
No . I want to optimize and shorten the code
The code has no problem, if you already have a bunch of these in one file then splitting to separate files will make things look cleaner
.toggleClass maybe?
To use toggleClass then he is going to do some refractoring on the Css and html
Yes, look properly at the if else block, It shows that the elements has their independent styles apart from what is being toggled
ALL .addClass and .removeClass AND the if can be removed and replaced with only .toggleClass without changing any HTML or changing functionality
But....
The BEST way to refactor this is to remove ALL the JS and use CSS media queries to auto-set dark mode if the user prefers it
The one that is not overwritten
What is the name of that class
True it's a killer for such low functionality
Am dictating from the way things like this example are likely to be achieved
ok . thank you man
Today's websites shouldn't even have a button for dark mode
The customer requested this
Обсуждают сегодня