Problem with jQuery .removeClass()

  • # May 18, 2013 at 5:15 pm

    The above pen illustrates a way to make a responsive layout that includes a sidebar. When the final breakpoint is met, the navigation disappears, and a navigation icon appears. When the icon is clicked, the navigation appears. I accomplished this with jQuery, and I’m using .addClass() to add class “close” to the icon so that, after the navigation is opened, when it is clicked on the navigation closes. It works, until you do it a second time. The second time around, the navigation opens and immediately closes. It seems as if the class “close” is not being removed after the first second click. Feedback/help is appreciated, thanks.

    # May 18, 2013 at 10:34 pm

    Check out these:

    1.) toggleClass( )

    2.) hasClass( )

    # May 18, 2013 at 11:28 pm

    Thanks John. I was able to get it working with toggleClass().

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.