Search code examples
jquerycssbackgroundtoggletoggleclass

How to get CSS background property to work with toggleClass() in jQuery?


I added a toggleClass() connected to an element that has background property to toggle with different background. Take a look at my Fiddle, so I tested it, and it turns out that the event isn't changing the background no matter whet! I tried everything I know with jQuery. Please, any help would be appreciated and thank you in advance :)


Solution

  • Use important tag on the class that will override the others

    Such as

    .div1 {
        background:transparent!important;
    }
    

    Now the gold background disappears when you click toggle