Похожие чаты

Best way for refactor this code ?

17 ответов

8 просмотров

Use a bunch of document.querySelectors if you want to convert to raw JavaScript

#HaDi- Автор вопроса
#HaDi
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?

Thomas
.toggleClass maybe?

To use toggleClass then he is going to do some refractoring on the Css and html

Thomas
No

Yes, look properly at the if else block, It shows that the elements has their independent styles apart from what is being toggled

Friday Candour [Ask to PM]
Yes, look properly at the if else block, It shows...

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

Thomas
But....

The one that is not overwritten

Thomas
What is the name of that class

Am dictating from the way things like this example are likely to be achieved

#HaDi- Автор вопроса
#HaDi
ok . thank you man

Today's websites shouldn't even have a button for dark mode

#HaDi- Автор вопроса

Похожие вопросы

Обсуждают сегодня

Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
Did you guys see the latest tweet from TonGifts? 🚀
Mike
44
Oh dear Tomas & the team I hope you will accept my feedback about what just happened!! Am writing this because team no longer answering me in the PM 1- Dentx has 10bill...
M E
5
Хотел бы спросить у знающих, правильную ли я выбрал книгу для начала изучения ассемблера Юрова В.И ? Или есть более лучшие книги для начала обучения?
Botsman
31
падает джоба хотя уже была собрана на соседнем namespace, куда капать? │ │ Copying blob sha256:2fa066caddb8f09a71082b03aa43046f79346a01d9c89e06a1f508bb1207dba5 427 │ │ Copyin...
Andrei St
6
Conversation at a festival with a non-crpto person (not a normie by any stretch, though): * person: tell me about crypto, me: ok, the original idea is p2p sound money for the...
molecular#123 🐓
25
Добрый день, не подскажите, если в OC-V3 поменять страндартную директорию /storage/ на /storage2/ - не будет сильно много проблем ?
Max Dubovsky
32
Здравствуйте. Задача состоит в том, чтобы сделать real-time чат в мобильном приложении. После передачи сообщения пользователем через веб-сокеты, для основного и долговременног...
🐾
5
find_package(KSysGuard CONFIG QUIET) set_package_properties(KSysGuard PROPERTIES PURPOSE "Framework for process listing. Required for the 'Attach to Process' feature" ...
Mikhail
5
$params = [ 'formid' => 'feedbackForm', 'formTpl' => '@CODE: <form class="form-validate" data-id="ajax_form"> <fieldset class="margin-bottom-md"> ...
Pathologic
1
Карта сайта