+ 1

What’s wrong with my code

I’m trying to use the ToggleClass method with Jquery. I wanted to be able to change the background color of the div cont (container), and also to do a night mode button. However the nigh mode button doesn’t change the background color of the cont div. And the cont div doesn’t change color either with the second button. Do you see what’s wrong in the code itself ? https://code.sololearn.com/Wz0vnn4687rp/?ref=app

19th Nov 2018, 1:21 PM
Andrea Vinci
Andrea Vinci - avatar
3 Respuestas
+ 1
The problem is that rule by id selector have more importance than by class... Try to add !important in background-color of your .nit class
19th Nov 2018, 1:48 PM
KrOW
KrOW - avatar
+ 1
whouah ! It works great. Thank you very much KrOW, I didn’t have any clue about !important
19th Nov 2018, 2:09 PM
Andrea Vinci
Andrea Vinci - avatar
0
Take note that its NOT suggested use important except rare cases.... Read here for futher info https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
19th Nov 2018, 3:07 PM
KrOW
KrOW - avatar