Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Problem with jQuery .removeClass()

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #44868
    martyd777
    Member

    http://codepen.io/Martin-Duran/pen/lDiyo

    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.

    #135580
    JohnMotylJr
    Participant

    Check out these:

    1.) toggleClass( ) http://api.jquery.com/toggleClass/

    2.) hasClass( ) http://api.jquery.com/hasClass/

    #135581
    martyd777
    Member

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.