Search code examples
javascriptjquerytwitter-bootstraptoggletoggleclass

Toggle class don't remove class


I'm trying to make an article add a class while a menu is open. So, when the button is clicked, this will show the menu and also certain item (the article) should get the class padded, and when we press the button again, the class padded must be removed.

Now, it's adding the class, but not removing it when the button is clicked again

http://www.bootply.com/xcfWMYveNe

Cheers


Solution

  • Use this jQuery method called "toggleClass"

    $('.tab-pane.active').toggleClass("padded");