+ 1

Change content colour

Is there a way for me to change all the colours of the content on the page to either black or white depending on if the use has clicked the button without a if else statement? E.g. the user clicks the button making the bg colour black and the text white. https://code.sololearn.com/W38C34qFFlQ3/?ref=app

12th Dec 2019, 2:39 PM
farhan bhatti
farhan bhatti - avatar
5 Respuestas
+ 5
Css vars do the magic...
12th Dec 2019, 4:58 PM
Alfred Juma
Alfred Juma - avatar
+ 2
Ever heard of CSS variables? Its pretty more convenient than manual one-by-one styling with JS. Refer to this link: https://dev.to/ananyaneogi/create-a-dark-light-mode-switch-with-css-variables-34l8 If you feel its kinda hard or complex for ya... remember we all (especially me, just leave a message if you want) got your back for any of your questions.
12th Dec 2019, 4:14 PM
Nootnoot
Nootnoot - avatar
+ 2
Alfred Juma ill try to look up how to use them
13th Dec 2019, 2:10 PM
farhan bhatti
farhan bhatti - avatar
+ 1
Try "toggle class"
12th Dec 2019, 2:48 PM
Mystic Life
Mystic Life - avatar
+ 1
SPICEAPPLE 🍎 { active: 0 } thanks ill take a look at it and see if i can understand and use it
13th Dec 2019, 2:08 PM
farhan bhatti
farhan bhatti - avatar