+ 4

Why isnt the code working?

The border in css is staying the same color when in changing it with toggleClass() and so is the text. How do i change it? https://code.sololearn.com/W0n0C6zoCsdE/?ref=app

9th Mar 2019, 4:06 PM
Gavin Macpherson
Gavin Macpherson - avatar
8 Answers
+ 2
Gavin I made a mistake when I posted the code Gavin Test previously. The code below has the correction to toggleClass and I also removed !important from CSS as it in not needed. https://code.sololearn.com/WCXYvm3pItl8/?ref=app
10th Mar 2019, 4:11 PM
ODLNT
ODLNT - avatar
+ 5
Add the !important to the border of .new border:5px solid blue !important;
9th Mar 2019, 4:16 PM
Seniru
Seniru - avatar
+ 4
Senior pasan how does that work I haven't learned that but I finished css?
9th Mar 2019, 4:35 PM
Gavin Macpherson
Gavin Macpherson - avatar
+ 4
Trying to change the border with toggling class will not work as it won't override the border property. But using !important will force to override any css rule defined for an element. Yes there is no lesson about !important in Sololearn. You have to refer for another resource https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity#The_!important_exception
9th Mar 2019, 5:04 PM
Seniru
Seniru - avatar
+ 4
Ok thanks for helping me with this
10th Mar 2019, 4:19 PM
Gavin Macpherson
Gavin Macpherson - avatar
+ 3
Seniru
9th Mar 2019, 4:35 PM
Gavin Macpherson
Gavin Macpherson - avatar
+ 3
Ok thanks
9th Mar 2019, 5:45 PM
Gavin Macpherson
Gavin Macpherson - avatar
+ 1
Seniru Pasan, Gavin McPherson $("p").toggleClass("new", "old") should be $("p").toggleClass("new old") source - http://api.jquery.com/toggleclass/#toggleClass-className-state https://code.sololearn.com/WA4w64I9pwbD/#html
10th Mar 2019, 6:51 AM
ODLNT
ODLNT - avatar